Security rules

NGB044: Public production source maps

Reads the Angular build target in angular.json and reports production builds that emit script source maps referenced from the bundles: sourceMap: true or { scripts: true } without hidden: true in the production configuration (or in the build options when the production configuration does not override them)..

Property Value
Rule ID NGB044
Category Security configuration
Default severity low
CWE CWE-540, CWE-200
Built-in presets recommended: warn, strict: error

Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.

What it checks

Reads the Angular build target in angular.json and reports production builds that emit script source maps referenced from the bundles: sourceMap: true or { scripts: true } without hidden: true in the production configuration (or in the build options when the production configuration does not override them).

Why it matters

Referenced source maps let anyone download the original TypeScript — comments, internal endpoints, feature flags, validation logic and occasionally secrets — which makes it much cheaper to find and exploit other weaknesses. Hidden source maps keep error-tracking uploads possible without advertising the maps to every visitor.

Detection behavior and supported patterns

  • projects.<app>.architect.build.configurations.production.sourceMap (targets in Nx-style workspaces)
  • Falls back to build.options.sourceMap when production does not set it; Angular defaults to no source maps in production
  • { "scripts": true, "hidden": true } is not reported (maps are emitted but not referenced)

Example

TypeScript
"production": { "sourceMap": true, "outputHashing": "all" }

Safer alternative

TypeScript
"production": { "sourceMap": { "scripts": true, "hidden": true }, "outputHashing": "all" }

Remediation

Set "sourceMap": false for production, or { "scripts": true, "hidden": true } if you upload maps to an error tracker, and keep .map files out of the deployed folder.

False-positive considerations

  • Teams that intentionally publish source maps (open-source applications) can disable this rule.

Known limitations

  • Whether the generated .map files are actually deployed (and served) is not visible; hidden maps copied to the web root are still downloadable.
  • Builders other than the Angular application / browser builders and custom webpack configs are not analyzed.

References

Run it

Shell
ngbastion explain NGB044