Security rules
NGB038: Sensitive form submission target
Reports <form> elements that contain password, one-time-code or payment-card fields and are submitted natively to an insecure or uncontrolled destination: a plain-HTTP action (high), an [action] / [attr.action] binding (medium), or an absolute URL on another origin (low).
| Property | Value |
|---|---|
| Rule ID | NGB038 |
| Category | Sensitive data & payment security |
| Default severity | high |
| CWE | CWE-319, CWE-201 |
| Built-in presets | recommended: error, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reports <form> elements that contain password, one-time-code or payment-card fields and are submitted natively to an insecure or uncontrolled destination: a plain-HTTP action (high), an [action] / [attr.action] binding (medium), or an absolute URL on another origin (low). Covers component templates and index.html.
Why it matters
A native form submission sends every field as-is to the action URL. Over HTTP the password or card number is readable and modifiable on the network; a bound action lets whoever controls the bound value (URL parameter, API response) receive the credentials; posting card data to a third-party origin is sometimes intended (3-D Secure, hosted payment pages) but must be reviewed.
Detection behavior and supported patterns
- Sensitive fields:
type="password",autocomplete="current-password|new-password|one-time-code|cc-number|cc-csc|cc-exp",name/formControlName/idclassified as credential or payment data (password,cvv,cardNumber, …) - Targets: static
action="http://…"(non-local host),[action]/[attr.action]bindings, absolutehttps://actions - Forms without
action(submitted through(ngSubmit)/ HttpClient) are not reported
Example
<form [action]="loginUrl" method="post"><input type="password" name="password"></form>Safer alternative
<form [formGroup]="login" (ngSubmit)="submit()"><input type="password" formControlName="password"></form>Remediation
Submit credentials and card data only to your own origin over HTTPS, preferably through Angular HttpClient instead of native form posts. Keep action constant; never bind it to data you do not fully control.
False-positive considerations
- Intended posts to a payment provider (3-D Secure ACS, hosted payment page) are reported with low confidence; document an exception.
Known limitations
- Fields are attributed to the closest preceding
<form>in the template (document order); fields placed after a form closes but before the next one are attributed to the earlier form. - Forms built with Renderer2 / DOM APIs are not covered; dynamic
form.action = …assignments are handled by NGB012 (scheme) and NGB011 (redirects).
References
Run it
ngbastion explain NGB038