Skip to content

AngularJS double compilation crosses the downgrade boundary

Technical analysis of AngularJS double compilation crosses the downgrade boundary.

@jeffreyciend.bsky.social
Nov 22, 20263 min read

ybrid Angular applications often keep old AngularJS templates while migrating individual components to modern Angular. downgradeComponent() makes that gradual path possible by placing an Angular component inside an AngularJS template. The adapter has to move DOM nodes between two compilation systems, and that handoff is where advisory GHSA-ffj9-42qx-f38h found a cross-site scripting flaw.

The affected package is @angular/upgrade. The advisory lists versions below 22.2.4 in the 22 branch, below 21.2.26 in the 21 branch, below 20.3.35 in the 20 branch, and 19.2.25 or earlier. The 19 branch is end-of-support and will not receive a patch. Fixed releases are 22.2.4, 21.2.26, and 20.3.35.

The adapter compiled live content

When the directive creates a downgraded component, DowngradeComponentAdapter.compileContents() prepares child nodes for content projection. The vulnerable implementation read the host element's live contents and passed them to AngularJS $compile().

The directive sets terminal: true but keeps AngularJS's default priority of zero. Other zero-priority directives on the same host can therefore run first. Directives such as ng-bind, ng-bind-html, or ng-transclude can write user-controlled data or insert linked nodes before the downgraded component compiles the contents.

AngularJS then evaluates interpolation or directive syntax in that dynamic content. A value containing {{constructor.constructor('alert(document.domain)')()}} is enough to demonstrate script execution in a vulnerable application. The exact payload depends on how the host template and data binding are written, but the security boundary is clear: content that was not part of the static template reached a compiler.

Who is affected

Pure Angular applications are not affected. The vulnerability requires a hybrid application using @angular/upgrade, a co-located AngularJS directive that populates the host element's contents, and user-controlled data in the resulting DOM.

Those conditions are narrow enough to make a blanket scanner result noisy. A dependency may appear vulnerable while the application never uses downgradeComponent() in this pattern. Conversely, an application with a custom wrapper can meet the conditions even when a search for a single directive name finds nothing.

Review templates that put ng-bind, ng-bind-html, ng-transclude, or custom linked-content directives directly on a downgraded component host. Pay particular attention to asynchronous downgradeModule() bootstrapping, where a child directive can execute before the downgraded directive's post-link step.

Patch or move the binding

Upgrade to a fixed Angular release for the supported branch. Applications on Angular 19 need a supported upgrade path because the advisory states that no patch will be issued for the expired LTS branch.

If an immediate upgrade is not possible, move the dynamic binding to an inner child element or pass the value through an Angular @Input() property. For transclusion, place ng-transclude on a wrapper child inside the component rather than directly on the downgraded host. Removing the co-located directive prevents dynamic content from reaching the vulnerable compile step.

These are containment measures, not a substitute for the fixed adapter. Test the actual hybrid template and confirm that the resulting DOM still renders data safely. A unit test that searches for the old directive string can miss a custom directive that inserts linked nodes.

Verification and detection

After upgrading, inspect the built dependency tree for a single resolved copy of @angular/upgrade. Check that the browser bundle no longer contains the vulnerable compilation path and that source maps and cached assets are invalidated.

In logs and browser telemetry, look for AngularJS expression syntax in user-controlled fields that flow into downgraded components. A CSP that blocks inline script can reduce impact, but it does not repair the unsafe compilation path and should not be treated as a complete fix.

The migration from AngularJS was supposed to reduce legacy risk. This advisory shows why the compatibility layer needs its own tests, dependency ownership, and upgrade deadline. Old template behavior can survive a framework migration even when the surrounding application looks modern.

References

Did you enjoy this article?

Recommend it — Standard Reader surfaces well-loved writing to more readers across the network.

Across the AtmosphereDiscussions