Skip to content

warn about missing SSRF protection config in angular v22 - #10523

Merged
leoortizz merged 20 commits into
mainfrom
leoortizz_angular22warning
Jun 11, 2026
Merged

leoortizz merged 20 commits into
mainfrom
leoortizz_angular22warning

Conversation

@leoortizz

@leoortizz leoortizz commented May 17, 2026 •

Copy link
Copy Markdown
Member

Description

Angular 22 enables strict SSR host validation by default. On Firebase Hosting Web Frameworks, SSR runs on Cloud Run behind a proxy with rotating hostnames, so without the right security.allowedHosts configuration the SSR responses start failing after deploy — a problem that never shows up locally and is hard to diagnose.

This PR adds a build-time pre-flight check for Angular 22 SSR projects. It asks one question — will the host the SSR engine actually validates be allowlisted? — where trustProxyHeaders just selects which host that is: the forwarded public domain when on, the raw Cloud Run host when off. When that host is missing it prints an actionable warning (with links to the official Angular docs) listing the hosts to add, and surfaces trustProxyHeaders only as an alternative. The check is best-effort and informational — it never blocks or fails the build, and it does nothing for older Angular versions, non-SSR apps, or already-configured projects.

Screenshot 2026-06-04 at 12 45 54

Scenarios Tested

firebase deploy

Scenario security.allowedHosts (angular.json) trustProxyHeaders (server entry) Branch exercised Expected runtime result
No config none none Engine validates the raw Cloud Run host, which isn't allowlisted ⚠️ Warning lists the recommended hosts, with trustProxyHeaders offered as an alternative → SSR request rejected
Wildcard hosts ["*"] none Wildcard satisfies every host ✅ No warning → SSR responds normally (HTTP 200)
Engine-level hosts none in angular.json (configured on the SSR engine instead) none Host allowlist treated as user-managed ✅ No warning → host validation left to the user
Partial hosts only *.web.app set Proxied mode validates the forwarded public domain; *.firebaseapp.com not allowlisted ⚠️ Warning flags only the missing hosts (*.firebaseapp.com, *.a.run.app) → SSR request rejected on the firebaseapp.com domain
Hosts only all recommended hosts none Engine validates the raw Cloud Run host, which is allowlisted ✅ No warning → SSR responds normally (HTTP 200)
Fully configured all recommended hosts set Nothing missing ✅ No warning → SSR responds normally (HTTP 200)
SSR disabled n/a (no SSR) n/a Non-SSR build short-circuits the check ✅ No warning → static site served (HTTP 200)

Sample Commands

firebase deploy

Angular 22 enabled strict SSRF protection on its SSR engine. Without
explicit configuration, Firebase Hosting SSR functions will return
errors due to rotating Cloud Run hostnames.

- Add security pre-flight check for Angular 22 SSR builds
- Detect missing `security.allowedHosts` in angular.json
- Detect missing `trustProxyHeaders` in server entry point
- Surface cohesive, indented warnings with links to official docs
- Add unit tests
@wiz-9635d3485b

wiz-9635d3485b Bot commented May 17, 2026 •

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 3 Medium
Software Management Finding Software Management Findings -
Total 3 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a security pre-flight check for Angular 22 SSR projects to ensure they are correctly configured for Firebase Hosting. It adds logic to detect missing allowedHosts and trustProxyHeaders settings, which are necessary for SSR to work with Cloud Run's rotating hostnames. Feedback from the review focuses on improving the accuracy of configuration detection through more specific regex patterns, optimizing build performance by eliminating redundant context resolution, and increasing robustness by dynamically identifying the server entry point from project metadata instead of relying on hardcoded file paths.

Comment thread src/frameworks/angular/utils.ts Resolved
Comment thread src/frameworks/angular/utils.ts Resolved
Comment thread src/frameworks/angular/utils.ts Resolved
Comment thread src/frameworks/angular/utils.ts Resolved
@leoortizz
leoortizz marked this pull request as ready for review May 18, 2026 17:13
@leoortizz

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a security pre-flight check for Angular 22 SSR deployments on Firebase Hosting. It adds logic to detect missing security.allowedHosts and trustProxyHeaders configurations, which are required for strict SSRF protection in Angular 22. The implementation includes new utility functions in src/frameworks/angular/utils.ts and comprehensive unit tests in src/frameworks/angular/utils.spec.ts. Feedback was provided regarding the robustness of the regex patterns used to detect configuration in the server entry file, as they may currently match occurrences within comments.


const declared = opts.buildOptionsAllowedHosts ?? [];
const serverHasAllowedHosts =
!!opts.serverEntrySource && /\ballowedHosts\s*[:=]/.test(opts.serverEntrySource);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex \ballowedHosts\s*[:=] might produce false positives if the string appears within a comment (e.g., // allowedHosts: []). While this is a best-effort check, consider a slightly more restrictive pattern or accepting that manual configuration in comments might suppress the warning.

Comment thread src/frameworks/angular/utils.ts Outdated
}

const trustProxyHeadersMissing =
!opts.serverEntrySource || !/\btrustProxyHeaders\s*[:=]/.test(opts.serverEntrySource);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to allowedHosts, the regex for trustProxyHeaders could match occurrences inside comments. Given the importance of this security configuration for Angular v22 SSR on Firebase, ensuring the detection is as robust as possible is recommended.

leoortizz and others added 11 commits May 18, 2026 15:50
Treated allowedHosts and trustProxyHeaders as two independent requirements, so
it warned even when the deploy would work (e.g. allowlisting *.a.run.app with no
trustProxyHeaders). Collapse to one check: is the Host the SSR engine validates
allowlisted? trustProxyHeaders just selects which Host that is, not a second
must-have. Recommend the full host set, show trustProxyHeaders only as an
alternative, and note custom domains there.

Verified on Angular 22.0 GA
@leoortizz
leoortizz force-pushed the leoortizz_angular22warning branch from 931c096 to aa831c0 Compare June 4, 2026 16:13
@leoortizz
leoortizz enabled auto-merge (squash) June 11, 2026 14:11
@leoortizz
leoortizz disabled auto-merge June 11, 2026 14:14
@leoortizz
leoortizz enabled auto-merge (squash) June 11, 2026 17:10
@leoortizz
leoortizz merged commit 9cbc0f1 into main Jun 11, 2026
51 checks passed
@leoortizz
leoortizz deleted the leoortizz_angular22warning branch June 11, 2026 17:40
bkendall pushed a commit that referenced this pull request Jul 9, 2026
* security(angular): warn about missing SSRF protection config in v22

Angular 22 enabled strict SSRF protection on its SSR engine. Without
explicit configuration, Firebase Hosting SSR functions will return
errors due to rotating Cloud Run hostnames.

- Add security pre-flight check for Angular 22 SSR builds
- Detect missing `security.allowedHosts` in angular.json
- Detect missing `trustProxyHeaders` in server entry point
- Surface cohesive, indented warnings with links to official docs
- Add unit tests

* fixes, PR comments, refactors

* fix: warn about Angular 22 SSRF config only when the host is rejected

Treated allowedHosts and trustProxyHeaders as two independent requirements, so
it warned even when the deploy would work (e.g. allowlisting *.a.run.app with no
trustProxyHeaders). Collapse to one check: is the Host the SSR engine validates
allowlisted? trustProxyHeaders just selects which Host that is, not a second
must-have. Recommend the full host set, show trustProxyHeaders only as an
alternative, and note custom domains there.

Verified on Angular 22.0 GA

* check version earlier

* changelog

* minor update in warning message
yuichi0301 pushed a commit to yuichi0301/firebase-tools that referenced this pull request Aug 16, 2026
)

* security(angular): warn about missing SSRF protection config in v22

Angular 22 enabled strict SSRF protection on its SSR engine. Without
explicit configuration, Firebase Hosting SSR functions will return
errors due to rotating Cloud Run hostnames.

- Add security pre-flight check for Angular 22 SSR builds
- Detect missing `security.allowedHosts` in angular.json
- Detect missing `trustProxyHeaders` in server entry point
- Surface cohesive, indented warnings with links to official docs
- Add unit tests

* fixes, PR comments, refactors

* fix: warn about Angular 22 SSRF config only when the host is rejected

Treated allowedHosts and trustProxyHeaders as two independent requirements, so
it warned even when the deploy would work (e.g. allowlisting *.a.run.app with no
trustProxyHeaders). Collapse to one check: is the Host the SSR engine validates
allowlisted? trustProxyHeaders just selects which Host that is, not a second
must-have. Recommend the full host set, show trustProxyHeaders only as an
alternative, and note custom domains there.

Verified on Angular 22.0 GA

* check version earlier

* changelog

* minor update in warning message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants