Triage a Scanner Finding
Investigate three static-analysis alerts. Trace sources and file-read sinks, inspect a catalog guard, distinguish confirmed findings from false positives, and identify missing evidence.
To triage a scanner finding, verify the reported claim against the real source, reachable sink, intervening controls, and deployment assumptions. Then record a confirmed finding, a bounded false-positive conclusion, or the evidence still needed. A highlighted line starts the investigation; it does not finish it.
This short lecture builds on Security Review Tools and Techniques. You will investigate three fictional alerts, inspect the code behind each, and choose both a verdict and a reason. The reading and practice are free. Sign in to save completion through the final review check.
Your brief: three alerts, one file-read sink
A public documentation site serves downloadable guides. The security rule is narrow: a request may select approved public documents, but must not choose arbitrary filesystem paths. The examples use a POSIX deployment with a public root at /srv/documents/public.
The scanner fixtures use the same broad rule and severity label. Your job is to determine whether each alert’s path-traversal claim is supported. The catalog and files in the controlled example are deployment-owned, and its listed documents are intentionally public.
1. Read the claim before choosing a verdict
Write the alleged failure in one sentence: “Request-controlled characters may choose a file outside the public document root before a file read.” This is more useful than treating “High” as the conclusion. You now have a property to check and a specific operation to trace.
| Check | Evidence to collect |
|---|---|
| Source | Which request value can the caller choose? |
| Reachability | Which branch and helper carry that value to this read? |
| Control | Where does the code reject an unauthorized selection? |
| Impact | Which files exist and are readable by the deployed process? |
| Next action | What fix, test, or missing implementation would resolve the claim? |
Tools model code rather than observing every possible runtime behavior. CodeQL’s data-flow documentation describes both the modeled graph and challenges such as unavailable implementations and runtime call targets. Keep the tool’s path and the application’s actual behavior as two pieces of evidence to reconcile.
2. Work through the triage queue
For each alert, inspect the source, resolver or guard, and sink in the compact explorer. Choose a disposition and the code fact that supports it. An answer is accepted in the practice only when those two choices agree.
Alert A: Request filename
Possible request-influenced path at readFile(filePath).
- Teaching rule
- CRL-PATH-READ-01
- Scanner severity
- High · unverified
- Claim to check
- Path traversal
This broad teaching rule does not model the custom resolver. Inspect the source, resolver and read before deciding.
The route is public. Only files under the public document root should be selected.
const file = String(req.query.file ?? '');
const filePath = documentPath(file);
The query parameter is caller-controlled. String conversion establishes a type, not a permitted file path.
Review question: Does the resolver merely produce an absolute path, or enforce the allowed directory?
Your triage decision
Choose both a verdict and its evidence. These practice decisions do not save path completion; the final review check below does.
3. Verify the fix with allowed and denied inputs
The documentation feature only needs a small catalog of public downloads. A checked document code can select a filename owned by the application. That removes the request’s ability to supply path syntax for this feature. Keep the root, catalog values, and document files controlled by the deployment.
Inspect the catalog-based repair
const DOC_ROOT = '/srv/documents/public';
const PUBLIC_DOCS = Object.freeze({
guide: 'guide.pdf',
api: 'api-reference.pdf',
});
export function publicDocumentPath(code: string) {
if (!Object.hasOwn(PUBLIC_DOCS, code)) return null;
const fileName = PUBLIC_DOCS[code as keyof typeof PUBLIC_DOCS];
return path.join(DOC_ROOT, fileName);
}
The route must still return before reading a file when the helper returns null. A safe helper does not help if a later fallback passes the original request value to another read.
expect(publicDocumentPath('guide')).toBe(
'/srv/documents/public/guide.pdf'
);
expect(publicDocumentPath('../private/payroll.csv')).toBeNull();
expect(publicDocumentPath('constructor')).toBeNull();
These checks test the selection helper. Also verify the route: an approved code must serve its intended document; rejected codes must return 404 without invoking the file read. A test that only rejects a malicious-looking value is incomplete if legitimate downloads stop working.
Do not generalize this repair to every file feature. Uploads, user-managed paths, private documents, and mutable storage need their own containment and authorization analysis. A lexical path check alone also does not establish where symlinks lead. The fixed, public, deployment-owned catalog is part of this example’s evidence.
4. Record a bounded triage decision
A useful triage note lets another security engineer reproduce your reasoning. State the rule and matched operation, source, path, decisive control or missing control, disposition, impact limits, and next action. Avoid closing every alert from the same rule because one path was controlled.
Compare a concise note for the controlled catalog path
The request supplies a document code. The own-key check permits only two fixed public catalog entries, and unknown codes return before readFile. On the shown route, the request does not control filename syntax, so the path-traversal claim is a false positive under the deployment-owned catalog assumptions. Preserve allowed/denied regression coverage and revisit this decision if catalog values become user-managed.
If suppression is appropriate, keep it specific to the reviewed claim and location, with the reason and test evidence. If the scanner needs a custom-helper model, verify that model’s contract before teaching it to ignore a path. Semgrep’s taint-analysis documentation explains how configured sources, propagators, sanitizers, and sinks affect what gets reported.
A confirmed boundary failure and a confirmed impact are different claims. In the direct-path example, the shown code permits an outside-root selection. Claims about reading a particular secret still require evidence about files, permissions, and the actual deployment. The OWASP source-code analysis overview also discusses the limits of proving a vulnerability from static-analysis output alone.
Complete your scanner triage
Loading question…