Counterweight Labs

Research

How to reduce recurring vulnerabilities in a SaaS codebase

Use repeated findings to identify shared design problems. Move from isolated patches to maintained controls, regression coverage, and a measure of recurrence.

Three application paths converge on a shared control followed by regression coverage.
In this guide

To reduce recurring vulnerabilities, identify the decision developers keep getting wrong and make the correct decision easier to reuse and verify. Fix the exposed instance promptly, then investigate why the same weakness can appear in another route, worker, or integration. Give the prevention work an owner and a completion criterion.

NIST's Secure Software Development Framework includes addressing root causes to reduce recurrence among its objectives. For an application team, that means connecting individual findings to the design, code, and delivery practices that produced them. A list of closed tickets is useful evidence of remediation, but it does not establish that the underlying cause has changed.Source: NIST Secure Software Development Framework 1.1

Group by cause before counting fixes

Take a bounded set of findings, such as the last assessment and the following release cycle. For each one, record the affected asset, the security rule that failed, the enforcement location, the fix, and the owner. Separate a reopened finding from a new instance of the same cause. Those two cases imply different work: verifying a previous fix versus changing a pattern that developers continue to copy.

Example grouping for a SaaS application
Repeated symptomPossible cause to investigateCandidate prevention work
Cross-tenant reads in several APIsData access permits unscoped queriesA tenant-aware access interface and denied-read tests
Exports remain accessible after permission removalAccess decisions are not rechecked at the required pointAn explicit export authorization lifecycle
Secrets appear in support bundlesDiagnostic collection copies sensitive configurationAn allowlist of diagnostic fields
Similar input-handling flaws recurDevelopers repeatedly implement a sensitive operationA reviewed shared implementation with constrained inputs

Treat the middle column as a hypothesis. Two findings with the same label may have different causes. A cross-tenant read through a normal API and a leaked signed download URL can both expose another tenant's data while requiring different fixes. Trace the actual operation before deciding that a shared helper solves both.

Change the interface developers use

Consider a hypothetical codebase with several invoice routes. Each route receives a general database client and is expected to remember a tenant filter. A review finds one missing filter. Patching that route is necessary; the prevention project is to decide whether ordinary handlers should be able to perform unrestricted invoice queries at all.

A candidate design gives ordinary request handlers an invoice-access interface that requires validated tenant context. Privileged operations use a separate path with explicit authorization and ownership. Review whether background jobs, admin tools, caches, and exports can bypass the new interface. Document the operations that remain deliberately privileged rather than disguising them behind a generic helper.

The migration needs a coverage plan. Inventory existing call sites, identify which can move immediately, and record exceptions that require separate work. A well-designed interface prevents little if most production paths continue using the old one. Review both the new implementation and evidence that the intended callers now use it.

API, bulk, and export paths feed a shared tenant-aware access interface before reaching invoices. A separate direct bypass is crossed out.
Illustrative prevention design. Verify that ordinary invoice paths use the reviewed access interface, close direct bypasses, and review deliberately privileged paths separately.

Test the boundary and its consumers

Use focused tests for the shared decision and representative integration tests for its consumers. In the invoice example, test an authorized read and a denied cross-tenant read through the public API. Include a path that creates a downloadable artifact, because a correct API response can coexist with an incorrectly accessible export.

Keep the original finding's reproduction steps with the regression case. Have a reviewer check that the test reaches the security decision and fails for the intended reason in the vulnerable version. Tests that fail because a service is unavailable or a fixture is missing do not demonstrate that the vulnerability is covered.

Measure recurrence without hiding coverage changes

For each reviewed defect family, track new confirmed instances after the shared control was introduced. Record the applications and release period assessed, the test method, and any changes in exposure. Report unresolved exceptions beside the count. This lets the team distinguish a successful migration from a period when nobody looked at the remaining paths.

Avoid measuring the program only by tickets closed or alerts dismissed. Both can increase without changing the application. Pair remediation throughput with evidence such as migrated call sites, negative-test coverage of sensitive operations, and whether follow-up testing finds the same cause again. Use the numbers to choose the next engineering task, not to imply a precise percentage reduction in risk.

Define a finish line for the prevention work

A completion criterion might require that all ordinary invoice reads use the reviewed access interface; remaining privileged paths have named owners; direct and export access pass the agreed negative tests; and the next assessment explicitly retests those boundaries.

Sources

  1. NIST Secure Software Development Framework 1.1 csrc.nist.gov

Bring your recent findings and the code paths they affect. We can identify recurring causes and build a remediation plan your engineering team can maintain.

Explore application security
Book a consultation