Contain exposure before editing everything
If a secret was exposed, revoke or rotate it through the owning service and remove it from active configuration. Deleting a token from source does not invalidate copies. Review access logs where available, and keep evidence sanitized so the investigation does not spread sensitive values.
Inventory public routes, administrative functions, background jobs, storage buckets, and deployment settings. Mark which operations handle sensitive data or irreversible effects. This list establishes the repair scope; scanning a repository alone cannot tell you which generated routes are reachable in the deployed environment.
Repair the control at its enforcing boundary
Enforce authorization on the server for the actor, action, and resource. Replace unsafe query construction with the appropriate parameterized interface, validate input against expected shapes, and constrain file sizes and outbound destinations. Choose controls that match the actual framework and installed library versions.
Illustrative scenario: an export route trusts an account identifier from the browser. Derive the permitted account from authenticated server context and reject mismatches. Add a regression test using another account, plus a legitimate export test so the patch preserves the intended workflow.
Verify, deploy, and document residual risk
Run focused abuse-case tests and relevant integration checks after each repair. Review dependency updates for compatibility and inspect the final configuration in a nonproduction environment. Keep rollback instructions, especially when a fix changes session handling, database access, or external service credentials.
Assign an owner and acceptance condition to remaining findings. Record which endpoints and actor combinations were checked and which were outside scope. A completed remediation ticket should link the failing scenario, patch, and successful retest; a generic statement that security was reviewed is insufficient.
Working sheet
| Finding | Repair direction | Completion evidence |
|---|---|---|
| Exposed token | Rotate and remove exposure path | Old token rejected |
| Cross-account access | Enforce resource ownership | Unauthorized request denied |
| Unsafe query | Use supported parameter binding | Injection test cannot change query intent |
| Unbounded upload | Constrain size and accepted content | Oversized input rejected safely |
Questions about how to secure AI-generated application code
Should I fix every scanner warning before release?
Triage findings by reachability, impact, and confidence. Explicitly accept or resolve material risk rather than treating warning counts as the decision.
Can frontend validation enforce permissions?
No. Treat the browser as untrusted and enforce protected operations on the server.
How should I use the working sheet?
Download the CSV and replace the sample rows with evidence from your repository. Record a clear acceptance check and an owner for each item. Keep unresolved assumptions visible rather than treating the example as a completed assessment.
Sources and further reading
Examples are illustrative. They are not customer results, security guarantees, or a substitute for checking the documentation for your installed version.
