Open Closed

How to set default MaxDepth for AutoMapper in ABP 8? #10545


User avatar
0
nhontran created

Hi ABP Support Team,

We recently received a HIGH severity security finding (CVE-2026-32933) related to AutoMapper in our current ABP version (8.0.2).

While our long-term plan is to upgrade to ABP 10 and replace AutoMapper with Mapperly, that migration will take some time. In the interim, we need an immediate mitigation. I noticed there is a code-level fix available for this issue in this PR: https://github.com/abpframework/abp/pull/25138.

Could you advise on the best way to implement this fix into our 8.0.2 environment?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    This vulnerability (GHSA-rvv3-g6hj-g44x) has been addressed in ABP 10.2 via [PR #25138](https://github.com/abpframework/abp/pull/25138), which sets a default MaxDepth = 64 for all AutoMapper maps.

    For ABP 8.x, you can apply the same mitigation without modifying framework code. Add the following to ConfigureServices in any of your modules:

    Configure<AbpAutoMapperOptions>(options =>
    {
        options.Configurators.Add(ctx =>
        {
            ctx.MapperConfiguration.Internal().ForAllMaps((typeMap, _) =>
            {
                if (typeMap.MaxDepth == 0)
                {
                    typeMap.MaxDepth = 64;
                }
            });
        });
    });
    

    This iterates over all registered maps and sets MaxDepth = 64 for any map that doesn't already have an explicit MaxDepth configured, which prevents the StackOverflow DoS caused by deeply nested object graphs.

    You'll need to add using AutoMapper.Internal; for the Internal() extension method.

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    nhontran created

    Hi @maliming, thank you for the prompt response

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.