Security rules

NGB096: Development server exposed to the network

Reports Angular dev-server settings that expose ng serve beyond the developer's machine: serve target options / configurations in angular.json with host: "0.0.0.0" (or ::), disableHostCheck: true or allowedHosts: true / ["all"], and ng serve commands in package.json scripts with --host 0.0.0.0, --disable-host-check or --allowed-hosts all..

Property Value
Rule ID NGB096
Category Security configuration
Default severity low
CWE CWE-1327, CWE-350
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

Reports Angular dev-server settings that expose ng serve beyond the developer's machine: serve target options / configurations in angular.json with host: "0.0.0.0" (or ::), disableHostCheck: true or allowedHosts: true / ["all"], and ng serve commands in package.json scripts with --host 0.0.0.0, --disable-host-check or --allowed-hosts all.

Why it matters

The dev server serves unminified code, source maps, proxied backend APIs (with the developer's cookies through proxy.conf.json) and environment files. Binding it to all interfaces publishes all of that on café and office networks. Disabling the Host check is worse: any website the developer visits can use DNS rebinding to make the browser read the dev server, and the proxied APIs, cross-origin.

Detection behavior and supported patterns

  • angular.json → architect|targets.serve.options|configurations.*: host = 0.0.0.0 / :: (low), disableHostCheck: true, allowedHosts: true | ["all"] (medium)
  • package.json scripts running ng serve with --host 0.0.0.0 (low), --disable-host-check, --allowed-hosts all (medium)

Example

TypeScript
"start": "ng serve --host 0.0.0.0 --disable-host-check"

Safer alternative

TypeScript
"start": "ng serve"

Remediation

Keep the default host (localhost) and Host check. If the server must be reachable from a container or device, bind it to that interface only and list explicit allowedHosts names instead of disabling the check.

False-positive considerations

  • Containers and devcontainers often need --host 0.0.0.0 inside the container; the finding is low severity and can be accepted with an exception when ports are only published to localhost.

Known limitations

  • Vite / webpack dev-server configuration files and Docker / devcontainer port mappings are not read.
  • Whether the machine is reachable from untrusted networks (firewall, container) is not known.

References

Run it

Shell
ngbastion explain NGB096