Skip to content

warn about missing SSRF protection config in angular v22#10523

Open
leoortizz wants to merge 4 commits into
mainfrom
leoortizz_angular22warning
Open

warn about missing SSRF protection config in angular v22#10523
leoortizz wants to merge 4 commits into
mainfrom
leoortizz_angular22warning

Conversation

@leoortizz
Copy link
Copy Markdown
Member

@leoortizz leoortizz commented May 17, 2026

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 an explicit allowed-hosts list and trusted proxy headers 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. When the required security configuration is missing, it prints an actionable warning (with links to the official Angular docs) listing only the pieces that need fixing. 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-05-18 at 14 48 53

Scenarios Tested

firebase deploy

Scenario security.allowedHosts (angular.json) trustProxyHeaders (server entry) Branch exercised Expected runtime result
No config none none All recommended hosts missing and proxy headers untrusted ⚠️ Warning lists both fixes → SSR request rejected
Wildcard hosts ["*"] none Wildcard satisfies host allowlist; proxy headers still untrusted ⚠️ Warning flags only trustProxyHeaders → SSR request rejected
Engine-level hosts none in angular.json (configured on the SSR engine instead) none Host allowlist treated as user-managed; proxy headers untrusted ⚠️ Warning flags only trustProxyHeaders → SSR request rejected
Partial hosts only *.web.app set Some recommended hosts missing; proxy headers OK ⚠️ Warning flags only the missing hosts (*.firebaseapp.com, *.a.run.app) → SSR request rejected for the rotating Cloud Run host
Hosts only all recommended hosts none Host allowlist complete; proxy headers untrusted ⚠️ Warning flags only trustProxyHeaders → SSR request rejected
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
Copy link
Copy Markdown

wiz-9635d3485b Bot commented May 17, 2026

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.

Copy link
Copy Markdown
Contributor

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

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 Outdated
Comment thread src/frameworks/angular/utils.ts Outdated
Comment thread src/frameworks/angular/utils.ts Outdated
Comment thread src/frameworks/angular/utils.ts Outdated
@leoortizz leoortizz marked this pull request as ready for review May 18, 2026 17:13
@leoortizz
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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.

}

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.

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