Security Review Tools and Techniques
Combine manual code review, SAST, dependency scanning, Semgrep, and CodeQL, and decide when a scanner finding is exploitable.
A security tool result is a hypothesis to verify against the actual code path. Trace the source, the sensitive operation, the controls, and the deployment conditions before accepting or suppressing an alert.
Compare manual review, SAST, dependency scanning, Semgrep, and CodeQL. Then triage a finding yourself and explain the disposition.
What you will be able to do
- Choose a tool based on the review question.
- Distinguish structural matches, data-flow paths, and dependency alerts.
- Verify sources, controls, callers, and scan coverage.
- Write a confirmed, controlled, or unresolved triage conclusion.
Choose a tool from the review question
A security review begins with an asset and a boundary. For a report download, the question may be whether a signed-in actor can read only reports authorized for that actor. For an uploaded file, it may be whether an attacker-controlled filename can escape a storage directory. For a template renderer, it may be whether user-controlled text is interpreted as template syntax. A scanner result is useful when it helps answer one of these questions or points to an unconsidered boundary.
Some questions are easy for tools. A rule can find direct uses of eval, insecure random-number generators, or a dangerous API. A data-flow analysis can connect a known request source to a known command or HTML sink across modeled transformations. A dependency scanner can match package versions to known advisories. Other questions need product context: which organization owns a report, whether a feature is reachable by untrusted users, whether a disabled service is deployed, or whether a compensating control is active in production.
Avoid the two extreme habits. One is treating the tool as an oracle: “High severity means exploitable.” The other is dismissing all alerts because some are noisy. Both discard evidence. A useful reviewer records what the tool found, what it did not establish, and the next code lookup or test that resolves the uncertainty.
Consider four layers of evidence:
| Layer | What it can show | What it does not automatically show |
|---|---|---|
| Syntax or pattern | A risky API or code shape exists. | A reachable untrusted caller or missing guard. |
| Data-flow path | A modeled source can influence a modeled sink. | Complete runtime semantics or the product's permission rule. |
| Configuration and deployment | A feature, dependency, or policy is enabled in a particular environment. | That a specific actor can exploit it. |
| Controlled test | A denied or allowed case behaves in a specific setup. | That every environment and alternate path behaves the same way. |
A strong decision combines the layers relevant to the claim. You do not need a full penetration test for every alert. You do need enough evidence to avoid promoting a suspicious line into an unsupported exploit story.
Manual review is the control plane
Manual review is not “eyeballing code until something looks wrong.” It is a sequence of hypotheses and traces. Start at a change, endpoint, job, or sensitive capability. Name actor, asset, action, and policy. Trace attacker-controlled values and trusted identity separately. Read nearby tests, configuration, and callers. Search for alternate paths. At each boundary, ask what statement proves the security property.
Manual review has strengths that static tools often lack. It can use domain meaning: a manager may edit a report but may not approve their own report; a customer may view an invoice summary but not the private attachment; a support operator may impersonate a customer only with audited consent. It can recognize that a custom helper already performs a check, or that a supposedly sanitized value is later used in a different context.
It can discover an abuse path that crosses business workflow states rather than a familiar source-sink pair.
Its limits are real too. Humans miss paths, tire, and bring assumptions from one file to another. An automated scan can surface overlooked uses of dangerous APIs or a dependency introduced by a transitive update. It can rerun the same checks after every change. The right workflow lets automation widen the search and uses manual reasoning to decide what the results mean.
For each alert you investigate, open the actual code. Do not triage from an alert title alone. The line highlighted by a scanner may be the sink, the source, or merely a convenient location in the data-flow path. Follow the trace in both directions. If a path crosses a helper, inspect its implementation. If a result seems impossible, check whether the tool modeled that helper or a framework route incorrectly.
Select each stage of triage. The rule is a hypothesis; your disposition should explain the actual path.
Rule. Read the rule’s claim and supported scope. A structural pattern, a taint path, and a dependency version alert provide different kinds of evidence.
Source. Trace the value backwards to its origin. Request parameters, stored uploads, and server-owned constants do not have the same trust properties.
Path. Follow transformations, branches, helpers, and alternate callers. Confirm the code is included in the relevant build and runtime.
Control. Check the exact control and its ordering. A fixed map can constrain a filename; path.join by itself does not prove containment.
const file = allowedDownloads[requestedKey];
if (!file) throw notFound();
return fs.readFile(file);
Disposition. Write confirmed when the path violates the rule, explain the controlling contract for a safe path, and keep missing evidence unresolved rather than silently calling it safe.
Review question: Could another caller or build configuration bypass the control you relied on?
What SAST actually analyzes
Static application security testing examines source code or compiled representations without executing the full application request in the target environment. It can search for syntax patterns, construct call graphs, model control flow, and analyze data flow. Tools vary in languages, inter-file support, framework models, rule quality, and deployment context. “We run SAST” does not imply every vulnerability class is covered.
A simple pattern rule might say: report every call to a dynamic execution function. It has high recall for that syntax, but many matches may be unreachable from untrusted input or intentionally restricted to trusted build tooling. A taint rule defines sources, sinks, and often sanitizers. It tries to report paths where data from a less-trusted source reaches a dangerous sink without an effective transformation.
This can be more focused, but only for sources and library behavior the analysis models. A custom request wrapper or serializer unknown to the tool can cause missed or spurious paths.
Static analysis is approximate. The tool cannot always know runtime values, dynamic dispatch targets, reflection behavior, feature flags, or external service responses. It may deliberately favor reporting a possible path rather than proving a concrete exploit. A scanner's data-flow graph is therefore a map to inspect, not a substitute for the real application's semantics. CodeQL's data-flow documentation explicitly distinguishes value-preserving flow from taint tracking, and local flow from cross-function/global analysis.
The source-sink vocabulary is useful but incomplete. An authorization flaw may have no obvious “dangerous function.” The sensitive operation might be an ordinary database read, with the vulnerability in a missing relation between actor and object. A hardcoded secret may be found by pattern or entropy, but exploitability depends on whether the credential is active and scoped. A state-machine flaw may require comparing several endpoints and time-separated actions. Use the tool's strengths without narrowing the review to what the tool can detect.
A realistic pattern alert
Suppose a rule finds every use of a process execution API:
Rule: node-process-execution
File: scripts/build-icons.ts:42
Matched: execFile("svg-optimizer", [sourcePath, outputPath])
Severity from rule metadata: high
The match proves a process is started. It does not prove an attacker can choose the executable, arguments, sourcePath, or outputPath in a production service. The file might run only during a controlled build, with fixed arguments and trusted repository files. Or a user upload may feed sourcePath into the build script on a server. Read callers and deployment. If the operation is reachable from untrusted content, inspect argument parsing and filesystem effects.
If not, document the scope and consider whether the alert should be tuned for build tooling.
The severity in a rule file is a prioritization hint, not a measured consequence in your environment. A reviewer should be precise: “Dangerous API present in a build script; no untrusted runtime route found” is better than “RCE critical” or “false positive” before the callers are checked.
A scanner flags fs.readFile(), but its argument comes only from a fixed server-owned map. What should you do?
Semgrep: structural rules and taint hypotheses
Semgrep can match code structure using rules and can model tainted input flowing from configured sources to configured sinks. Its official rule ideas show both dangerous-API patterns and taint-oriented rules, and its glossary describes sources, sinks, sanitizers, and analysis scope. The exact capabilities of a scan depend on the engine, language, rule, and configuration in use; do not assume a rule sees across files just because a product can support cross-file analysis in some modes.
A structural rule is useful when the dangerous behavior has a recognizable shape. For example, a custom rule may flag a raw HTML rendering API or a call to a known insecure wrapper. The reviewer still asks whether the matched value is attacker-controlled and whether context-aware protection occurs earlier. A rule for every use of an API may be appropriate as a mandatory-review flag even when some uses are safe. Its alert message should say “review this use,” not “confirmed exploit.”
A taint rule asks a narrower question. For example: can a value read from a request parameter reach an HTML rendering sink without an approved encoder? The rule author must define the relevant request source, the sink behavior, and what sanitization is valid for that sink. A generic string replacement is not necessarily safe for HTML, SQL, shell arguments, and URLs alike.
If a custom helper performs output encoding, a scanner may need a model of that helper to avoid false positives. If a helper only validates length, modeling it as a sanitizer would produce dangerous false negatives.
Use small rule tests. Include an unsafe example that must alert, a safe example that must not, and a variant crossing a helper or alias. A rule that only passes the exact code that inspired it may fail on a harmless refactor or a slightly different vulnerable path. Review the rule's false-negative cost before adding broad exclusions.
For a triage note, record the rule ID and version, matched location, observed source, sink, and any modeled sanitizer. Then read the real code. If the rule points at a helper called escapeHtml, verify what context that helper handles and whether this route uses it before rendering. A name is not proof of protection. If the rule misses a custom source, improve its source model or keep manual review coverage for that boundary.
CodeQL: ask about paths, then inspect them
CodeQL represents code in a database that queries can analyze. Its data-flow libraries model how values or tainted influence move through a program. CodeQL path queries can show a candidate path from source to sink, which is especially useful when a value travels through several functions. GitHub code scanning can run CodeQL and surface alerts, but the exact queries, language support, and schedule depend on setup and configuration. Check the repository's actual configuration before assuming a finding class is covered.
A path display can make a multi-file review faster. It may show request query → helper argument → service return → command execution. The path is still a model. A control flow condition may make the path impossible for an untrusted actor, a framework source may be misidentified, or a custom sanitizer may be unmodeled. Conversely, a missing model can hide a true path. Read each hop and the conditions under which it runs.
Use CodeQL in three modes of work. First, consume existing alerts and verify their paths. Second, search for variants: if one vulnerable helper is found, ask what other callers reach the same sink. Third, refine a query or model for a custom framework that the default analysis does not understand. A security engineer need not become a query-language expert before using the first two modes, but should know what a path query claims.
Suppose a path shows req.query.template → renderTemplate. The reviewer should determine whether renderTemplate interprets template syntax or merely interpolates text into a fixed template. They should inspect whether req.query.template is actually used or overwritten by an allowlisted ID. They should check if the route is authenticated, what role is required, and what the rendered result can access. A path is an efficient hypothesis generator, not a full impact statement.
When reviewing a CodeQL alert in a repository, click through the source and sink, not only the first and last labels. If the path crosses a serializing or validation helper, open that helper. Search for a regression test. If an alert is dismissed, record the reason in terms of actual code and deployment. “Not exploitable” without a reason will not help the next reviewer after a refactor.
Dependency scanning answers a different question
Software composition analysis (SCA) identifies components and versions and compares them with known advisories. It can be applied to direct and transitive dependencies, lockfiles, manifests, built artifacts, or software bills of materials, depending on the tool. This is not the same as source-code SAST. A dependency alert says a vulnerable version may be present; it does not prove that the vulnerable function is used by this application or that an attacker can reach it.
The reverse is also important: absence of an advisory does not prove a package is safe. Advisory databases are incomplete, private vulnerabilities may not yet be disclosed, package identification may be wrong, and build artifacts can differ from manifests. Dependency scanning is a necessary inventory and update signal, not a guarantee.
For each advisory, check:
- Identity: Is the component and version correctly identified? Is a similarly named package being confused with another ecosystem?
- Presence: Is the vulnerable version in the deployed artifact, a development-only tool, an optional feature, or an old lockfile?
- Exposure: Does the application invoke the affected feature, parser, protocol, or configuration?
- Prerequisites: Does an attacker control the input described by the advisory? Is authentication or a particular deployment mode required?
- Remediation: Is a fixed version available, and can it be adopted safely? Is there a vendor mitigation or a compensating control?
- Evidence: What can be tested or inspected to verify the risk and the fix?
Do not dismiss a vulnerable development dependency automatically. A build tool can process attacker-controlled repository content in a continuous integration runner with secrets. Do not declare every transitive alert exploitable either. Describe the actual environment. GitHub's supply-chain guidance and the OWASP Vulnerable Dependency Management Cheat Sheet are useful primary references for inventory, updates, and documented false-positive treatment.
A package update may change behavior. Review its changelog, test the affected integration, and verify the vulnerable version is absent from the built artifact. A suppression that simply hides the alert without a dated rationale can let risk persist indefinitely. If no fix exists, document exposure, temporary controls, owner, and review date.
Two advisory examples
Imagine a vulnerable image decoder is installed as a direct dependency, but the deployed service never imports it; it is used only by a local design-preview script. That changes immediate remote exploitability. It does not make the alert meaningless: the script may process untrusted images on developer machines or in CI. Record where it runs, what files it reads, and whether it has sensitive credentials.
A reasonable disposition could be “not reachable in production service; update build tool and review CI input,” rather than “critical remote code execution” or “ignore.”
Now imagine the same decoder handles user-uploaded profile images in the production worker. A vulnerable parsing path may be reachable even though the HTTP handler itself only enqueues a job. Trace the upload through storage and queue to the decoder. Check size and format validation, sandboxing, and the advisory's actual affected function. The same dependency and version can have different exposure in two deployments.
Triage a scanner alert using a fixed sequence
Use the following sequence before changing code or dismissing a result:
1. Read the precise claim. Record rule ID, location, category, source, sink, path, and tool version. An alert labeled “path traversal” may merely highlight a file API; the full rule description may say it reports any nonliteral path.
2. Establish reachability. Identify the route, job, CLI command, or test that calls the code. Determine who can trigger it and what authentication or configuration applies. Trace alternate callers if the flagged function is shared.
3. Trace attacker control. Which value can the actor choose? Does it survive parsing, lookup, normalization, and mapping into the sink? A request key that selects only among fixed server-side paths is different from an arbitrary path string.
4. Inspect controls at the right context. A length limit is not a path-traversal defense. An HTML encoder is not a SQL parameterizer. A role check may not enforce object ownership. Verify the control's implementation and whether this path executes it before the sensitive effect.
5. State the impact with deployment assumptions. What file or operation becomes reachable? Is it read, write, or execution? What environment and privileges does the process have? Avoid promoting a hypothetical worst case into an observed fact.
6. Test one denied and one allowed case. Use approved test data. A denied test should fail without sensitive side effects; an allowed test ensures the feature still works. If a runtime test cannot be performed, record the remaining uncertainty and why.
7. Decide and document. Confirmed issue, false positive, risk accepted with controls, or unresolved pending evidence are different dispositions. A useful note includes the code path, reason, owner, and a revisit trigger.
This sequence is intentionally similar to manual multi-file review. The tool supplies a starting hypothesis; the reviewer supplies a security property and evidence.
Constrain which files a request can select
The caller should choose only a public guide or checklist. How does the second version express that limited feature?
const path = join(downloadRoot, String(req.query.name));
return fs.readFile(path);
Reveal the safer implementation
const publicDownloads = new Map([
["guide", "/srv/public-downloads/guide.pdf"],
["checklist", "/srv/public-downloads/checklist.pdf"],
]);
const path = publicDownloads.get(String(req.query.name));
if (!path) throw notFound();
return fs.readFile(path);
The requested value selects one of two server-owned public resources. It no longer supplies a path segment. If the feature needs user-owned dynamic files, this fixed-map design will not be enough; review authorization, canonical paths, containment, and symlink behavior for that design.
Worked scanner finding: a dangerous-looking file API
The fictional Northstar Portal serves two public PDFs bundled with the application. A SAST rule flags the call to sendFile because the route contains a path parameter. Decide whether the shown source creates a path-traversal vulnerability.
Rule: user-controlled-file-path
Message: A request value may influence a file path passed to sendFile.
Source: req.params.documentKey
Sink: res.sendFile(filePath)
Location: controllers/publicDocument.ts:18
Read the actual code:
// publicDocuments.ts
const publicDocuments = new Map<string, string>([
['privacy', 'privacy-v4.pdf'],
['accessibility', 'accessibility-v2.pdf'],
]);
// publicDocumentController.ts
const DOCUMENT_ROOT = path.resolve(process.cwd(), 'public', 'documents');
export async function download(req, res) {
const fileName = publicDocuments.get(req.params.documentKey);
if (!fileName) return res.sendStatus(404);
const filePath = path.join(DOCUMENT_ROOT, fileName);
return res.sendFile(filePath);
}
The request controls documentKey, which selects one of two entries from a server-defined Map. It does not become the fileName. The Map values are fixed names in source code. An unknown key returns 404 before the sink. On the shown route, the claimed source-to-sink path is not valid: the potentially dangerous operation receives a path assembled from a fixed root and an allowlisted filename.
The correct disposition is a likely false positive for user-controlled path traversal, assuming no other code can mutate the Map or DOCUMENT_ROOT at runtime.
Do not stop at “there is a Map.” Verify the values and mutability. A Map populated from database records edited by users would have different trust properties. A helper could add entries at runtime. The root might be configurable from an untrusted environment in an unusual deployment. An untrusted key might cause a different side effect before the lookup. Those are concrete things to inspect, not reasons to report the shown snippet as exploitable.
Write a triage note:
The public document route maps documentKey through a fixed two-entry server-side Map. Unknown keys return before sendFile. The request value is used only for lookup; neither the joined filename nor root is derived from the request on this path. No user-controlled traversal path is demonstrated. Keep a test that unknown keys return 404 and a rule test that still alerts when a request path is passed directly to sendFile. Reopen if document mappings become user-editable.
This note states the limited evidence. It does not claim all uses of sendFile in the application are safe. It gives a future reviewer a condition that would change the decision.
Compare a real unsafe variant
The following different route removes the server-side mapping:
export async function downloadAny(req, res) {
const filePath = path.resolve(DOCUMENT_ROOT, req.query.name);
return res.sendFile(filePath);
}
Here the caller-controlled name is used in path resolution. A valid-looking file name does not imply it stays under DOCUMENT_ROOT. The security rule needs to confine the resolved path or, preferably for this feature, use an opaque identifier mapped to approved documents. The scanner's source-to-sink concern is now supported by the code. Before claiming a particular file can be read, verify the framework's sendFile behavior, process permissions, and how the route handles invalid paths.
The comparison shows why a call name alone cannot decide the alert.
Exercise: decide whether an alert is exploitable
A scanner reports “untrusted path passed to file read” in a fictional profile badge service. The service is public and lets visitors request a badge by code. The code is below. Pause and write a decision of three to five sentences before reading the answer notes. Your answer must name source, sink, transformation, guard, and one condition that would change the result.
// badgeCatalog.ts
export const BADGES: Readonly<Record<string, string>> = Object.freeze({
helper: 'helper.svg',
mentor: 'mentor.svg',
contributor: 'contributor.svg',
});
// badgeController.ts
const BADGE_ROOT = path.resolve(process.cwd(), 'public', 'badges');
export async function badge(req, res) {
const code = String(req.params.code);
const fileName = Object.prototype.hasOwnProperty.call(BADGES, code) ? BADGES[code] : undefined;
if (!fileName) {
return res.sendStatus(404);
}
const svg = await fs.promises.readFile(path.join(BADGE_ROOT, fileName), 'utf8');
return res.type('image/svg+xml').send(svg);
}
What if a later change loads BADGES from an admin-editable database table? What if a user can upload badge SVG content while retaining the same fixed filenames? Do those changes affect the path-traversal conclusion, the content-safety conclusion, or both? Keep the questions separate.
Compare your reasoning
The route source is req.params.code. The sensitive sink is readFile. The code first requires code to be an own key of the frozen, server-defined BADGES object; the fileName passed to path.join is one of three fixed values. The shown code does not demonstrate a request-controlled path traversal. A concise triage conclusion is “false positive for the path traversal claim on this path, given the fixed catalog shown.” A regression test can verify that unknown codes return 404 and no file read occurs.
Loading BADGES from an admin-editable table would change the trust source of fileName. The reviewer would need to examine admin permissions and whether table values are restricted to known filenames. Allowing user-uploaded SVG content would raise a separate content-safety question: SVG can contain active content in some rendering contexts. Fixed filenames alone would not answer that issue. One finding should not be stretched to cover unrelated risks without evidence. Explain the source-to-sink reasoning; the words “false positive” alone are not a review.
False positives, false negatives, and unresolved results
A false positive is a tool report whose claimed security condition does not hold in the reviewed context. In the fixed Map example, the request string cannot become a filesystem path on the shown path. The tool may conservatively treat any value selected by a request key as tainted; a reviewer can identify the stronger allowlist guarantee. A false positive is a property of the claim and context, not a synonym for “low severity” or “annoying.”
A false negative is a real issue the tool did not report. A custom wrapper may hide the dangerous sink, an indirect callback may evade the call graph, a business rule may not be expressible as a generic rule, or a dependency may be absent from the manifest the scanner reads. Manual review and targeted tests still matter. Improving tool coverage requires adding models, rules, or data sources, not pretending a clean scan is proof of safety.
An unresolved result is one where available evidence does not yet decide the claim. Perhaps the code is behind a feature flag whose production state is unknown, or a database policy may enforce the missing boundary, or a dependency is present only in a build artifact you cannot inspect. Mark it unresolved, assign the exact question and owner, and do not silently dismiss it. This keeps uncertainty visible without inflating it into a confirmed exploit.
A valid finding with limited exposure is different from a false positive. If an unsafe deserializer runs only in a privileged admin workflow, the bug may be real but require an admin actor or a compromised input source. Report the actual prerequisites and impact. A severity label may change; the underlying condition does not vanish.
The distinction matters for metrics. Teams that count every alert as a vulnerability create noise. Teams that count every dismissed alert as a false positive hide coverage gaps. Track dispositions in a way that supports learning: confirmed issues, ruled-out claims, accepted risks, duplicates, and pending evidence. The goal is better security decisions, not a cosmetically low alert count.
Tune rules without creating blind spots
Suppression is sometimes appropriate, but it needs a reason tied to code and scope. If a rule flags the two fixed public PDFs, a narrowly scoped suppression on that call may be defensible after review. A repository-wide exclusion for all sendFile uses would hide future unsafe routes. A rule change that treats every function named sanitize as safe could create false negatives. Prefer a tested model of the actual sanitizer behavior.
Good rule hygiene includes:
- A clear message stating what the match means and what the reviewer must verify.
- Positive and negative test cases, including helper and alias variants.
- Source and sink definitions that match the framework in this repository.
- Sanitizer definitions specific to the context they protect.
- Narrow path exclusions with ownership and review dates.
- A way to reopen a dismissed result if the relevant code or configuration changes.
For Semgrep, a pattern rule can flag all uses of a dangerous API as a review trigger. A more precise taint rule can focus on user-controlled values reaching it. For CodeQL, a custom data-flow model can connect framework-specific sources or sinks. Neither approach should hide an unmodeled business authorization rule. The review plan should still include manual checks for high-value workflows.
When a finding is true, prefer fixing the code and adding a regression test. Do not write a suppression because a fix is inconvenient. When a finding is false, explain why and consider whether the rule can be improved. A suppression file without rationale, owner, or expiry is technical debt in the security signal system.
A dependency scanner finds a vulnerable package version. Which statement is immediately supported?
Walk a dependency alert through a deployed worker
Consider a fictional image-processing service. A dependency scanner reports that version 3.2 of pixel-parser has an advisory involving a crafted image header. The alert appears in the API repository's lockfile. The scan does not tell you whether an uploaded image can reach the affected parser in production. The first useful question is where that version is installed and executed.
The application has an API route that accepts uploads, stores the file, and enqueues a resize job. A separate worker reads the queued object and calls pixel-parser.decode. The worker is deployed with the same lockfile version. The advisory says the issue affects the decode path for a particular image format. The upload route checks a declared MIME type but does not parse file content. What can you conclude?
Start with the inventory. The vulnerable package version appears in the worker's built artifact, not merely in a development manifest. Then trace the input. A user-controlled file reaches object storage, a job message carries the object key, and the worker retrieves the bytes. The relevant source is the uploaded file content. The sensitive operation is decoder processing.
The route's MIME check may help product behavior, but a client can claim a MIME type that does not match bytes. It does not prove the decoder never sees the affected format.
Now inspect the worker call. Does it call decode for every upload, or does another library identify and reject the affected format first? If it rejects by examining file bytes, verify that it runs before the vulnerable decoder and that its validation cannot be bypassed by polyglot or malformed files relevant to the advisory.
If a server-side format conversion normalizes the bytes before decode, inspect which library performs that conversion; the conversion might itself be the vulnerable parser. Names such as “sanitizeImage” are not proof of safety.
The advisory's actual prerequisites matter. It may require a rarely enabled option, a specific architecture, or a file size that the upload route rejects. Check those facts against the installed package and worker configuration. A scanner label saying “critical” cannot tell you whether the option is enabled. Conversely, a file-size limit does not rule out a parser flaw unless the advisory requires a larger file. Document the exact point of agreement or disagreement.
Suppose inspection shows the worker calls the affected decoder on uploaded files and no earlier control excludes the format. You have a reachable vulnerable dependency path. You still may not know whether the crafted input causes a crash, memory exposure, or code execution in this deployed worker; do not borrow the broadest consequence from an advisory without checking its conditions.
A precise triage note might say: “User-uploaded bytes reach the affected decoder in the production resize worker. The installed version is within the advisory range. The package should be updated promptly; exploit behavior has not been reproduced in this environment.” That is a valid finding with explicit evidence and limits.
If a fixed version exists, plan the update and verify the result in the built worker artifact. Running an update command in the API repository is not enough if deployment still contains the old worker image. Test normal image workflows and failure handling after the update. If no patch is available, evaluate a temporary restriction or isolation measure, assign an owner and review date, and keep the alert visible.
The final disposition may differ from a source-code alert because the remediation is a package and deployment change rather than a line-level code fix.
A compact evidence matrix
| Question | Evidence to collect | Why it matters |
|---|---|---|
| Which version is deployed? | Worker artifact or dependency manifest used by its build | Lockfile presence alone may describe the wrong environment |
| Can an attacker supply bytes? | Upload route, storage write, queue message, worker read | Establishes the input path |
| Is the affected feature used? | Actual decoder call and options | Tests advisory prerequisites |
| Does an earlier control exclude it? | Content inspection order and denied tests | Distinguishes a real guard from a label check |
| What fix is available? | Vendor advisory and fixed release | Guides remediation and verification |
This exercise is a reminder that dependency triage and code review meet at runtime paths. The package inventory starts the investigation. The application code decides whether the advisory's vulnerable function is exposed. The deployed artifact confirms what version actually runs. A useful decision cites all three.
Check the scanner's coverage before trusting silence
An alert is evidence about a path the tool saw. A clean result is evidence only about the files and rules that actually ran. Before using a scan to support a release decision, inspect its coverage. Did it analyze the current revision or an earlier commit? Did it scan every relevant language and generated service? Did it skip vendored code, test helpers, or a worker directory? Were the taint rules enabled? Was the dependency scan based on a lockfile that matches the deployed image?
Consider a repository with a TypeScript API, a Python image worker, and Terraform deployment files. A CodeQL run configured only for JavaScript may thoroughly inspect the API while saying nothing about the Python parser path. A Semgrep scan restricted to src/api can miss a custom authorization helper in packages/shared. A dependency scan of the root lockfile may miss a second lockfile under the worker directory.
These are coverage gaps, not proof that any specific vulnerability exists. List them as review limitations and decide whether an additional scan or manual trace is needed for the feature under review.
Baseline and diff scans also answer different questions. A diff scan highlights new findings introduced by a change; it can leave an old vulnerable helper in place if the new route begins calling that helper. Review the caller change and inherited sink together. A baseline scan may generate many pre-existing alerts; triage them by reachable paths and priority. If the team's process ignores all baseline alerts, a new entry point can make an old line newly exploitable without a new alert at that line.
For custom rules, read the rule configuration when a result seems surprising. A rule that models req.query but not a GraphQL argument or queue payload will miss those sources. A rule that treats every function named escape as a sanitizer may suppress paths where the function only URL-encodes input before HTML rendering. The correct response is to improve or supplement the model and add positive and negative rule tests. Merely increasing the rule's severity does not increase its coverage.
Write a coverage statement in review notes: “The configured scan analyzed the current TypeScript API revision with rules X and Y; it did not analyze the Python worker or the shared package.” This sentence makes the scan useful and honest. It tells the next reviewer exactly where manual work or additional automation belongs.
Build a practical review routine
A small team can combine tools and human work without turning every change into a ceremony. For a new endpoint:
- Write the security question: who may perform which action on which object?
- Review the changed code and one call upstream and downstream.
- Run the repository's configured SAST and dependency scan; note what actually ran.
- Triage new alerts using source, sink, reachability, control, and impact.
- Search for variants of any confirmed issue, especially shared helpers and alternate routes.
- Add an allowed and a denied test for the important boundary.
- Record unresolved questions and owners before release.
For a large existing codebase, prioritize high-impact areas: identity, object authorization, file and command operations, external network calls, secrets, exports, and privileged workers. Use scanners to inventory risky patterns, but do not let alert volume define priority by itself. A quiet scanner in a poorly understood money movement workflow is less reassuring than a tested invariant in that workflow.
For dependency updates, make the inventory repeatable: lockfile or build artifact, advisory source, version resolution, exposure assessment, and patch verification. Review transitive packages when a new vulnerability affects them. Re-run scans after fixes because a suppressed old alert or stale artifact can create a misleading green result.
When a scanner and manual review disagree, resolve the precise disagreement. The tool may claim a tainted path that is cut by an allowlist; show the allowlist and test it. A reviewer may claim a safe path that the tool traces through an unmodeled helper; inspect the helper and runtime binding. The aim is not to “win” against the scanner. It is to establish the actual security property.
A concise triage note template
Use this template for a real alert:
| Field | Write down |
|---|---|
| Claim | Rule ID, tool version, file/line, reported source and sink. |
| Reachability | Route, job, build step, or other caller; actor and configuration. |
| Data path | Value and transformations from source to sensitive operation. |
| Control | Exact validation, authorization, encoding, or allowlist, with code evidence. |
| Impact | Realistic asset and effect under stated prerequisites. |
| Test | Denied and allowed cases, or the reason a test could not run. |
| Disposition | Confirmed, false positive, limited exposure, or unresolved. |
| Follow-up | Fix, rule tuning, owner, and revisit trigger. |
One paragraph can carry these fields for a small finding. The table is a reminder to avoid one-line dismissals. A future reviewer should be able to re-open the code and understand why the conclusion was reached.
The SAST run reports zero findings. What is a sound review conclusion?
Common misconceptions
“A clean scan means this path is secure.” Coverage depends on language, rules, models, files scanned, and configuration. Business authorization and time-separated workflows often require manual reasoning.
“High severity in the tool means confirmed high impact.” Rule metadata prioritizes review. Actual impact requires a reachable actor, affected asset, and deployment context.
“Any dynamic path is path traversal.” The path may come from a fixed server-side map. Trace the value that actually reaches the file API.
“A false positive can be dismissed without explanation.” Code and configuration change. Document the decisive guard and a revisit condition.
“An outdated dependency is harmless if imported nowhere.” It may run in a worker, build process, or transitive feature. Determine the actual deployed and operational exposure.
“A sanitizer name proves safety.” Verify the implementation and output context. A helper safe for HTML text may not be safe for an attribute, URL, script, SQL query, or shell command.
“A scanner path proves exploitability.” It shows a modeled path. Inspect guards, runtime conditions, and the asset at the sink.
“Manual review is just a second scan.” Manual review supplies policy, product meaning, alternate workflow context, and decisions tools do not inherently know.
Practice before the next lecture
Complete the interactive lecture, Triage a scanner finding. Investigate three alerts, inspect their source-to-sink paths and guards, choose a disposition with supporting evidence, and pass its final review check to save this lecture to your path.
Take a new scanner alert from a repository you are allowed to inspect, or reuse the badge exercise. Write the exact claim in one sentence. Trace the source and sink across files. Find the guard and inspect its implementation. State what a denied test would look like. Then assign one of the four dispositions with a reason. If the case remains unresolved, name the missing evidence instead of guessing.
Do the same for a dependency advisory. Identify the actual package version in the built environment, the affected API or configuration, whether the application reaches it, and the available fix. A good note may recommend an update even when immediate exploitation is not demonstrated. Separate “not currently reachable” from “not worth fixing.”
In Your First Complete Security Review, you will put these tool-assisted hypotheses inside a full review: scope, trace, verify, report, and repair.
Key terms
- SAST: Static application security testing of code or compiled representations without running the complete target workflow.
- SCA: Software composition analysis that inventories dependencies and compares versions with vulnerability information.
- Pattern rule: A check for a code structure or API use, often useful as a review trigger.
- Taint analysis: Modeling whether data influenced by a source can reach a sink through transformations.
- Source: A value or operation that introduces untrusted data into a modeled flow.
- Sink: An operation where the data could cause a sensitive effect.
- Sanitizer: A transformation or check that makes a value safe for a specific use, if correctly modeled and applied.
- Path query: A query that can present a candidate route through a data-flow graph from source to sink.
- False positive: An alert whose claimed security condition is not present in the reviewed context.
- False negative: A real issue the configured analysis does not report.
- Suppression: A documented decision to hide a specific alert or rule result; it should be narrow and revisitable.
- Reachability: Whether an actor or workflow can execute the reported path under real conditions.
Frequently asked questions
Should I run Semgrep or CodeQL first?
Use the tools already configured and supported by the repository, then choose based on the question. A targeted structural rule can quickly inventory a dangerous API. A CodeQL path query can help explore a modeled source-to-sink chain. Neither is a universal replacement for the other or for a review of the product's permission rule.
Does a dependency alert always require an urgent production fix?
The version and advisory merit prompt triage. Urgency depends on whether the affected component is deployed, whether the vulnerable feature is used, attacker prerequisites, impact, and available remediation. Document a plan even when the immediate production path is not reachable. Do not use “dev dependency” as a blanket dismissal.
What evidence is enough to call an alert a false positive?
Show the exact code or configuration that breaks the claimed path, such as a fixed server-side mapping that prevents a request value from becoming a file path. Include a denied test when practical and a condition that would invalidate the conclusion later. A feeling that a rule is noisy is not evidence.
Can I suppress a rule after one safe example?
Suppress the specific safe instance with a reason, or refine the rule with positive and negative tests. A broad rule disable can hide future unsafe uses. Review the suppression when the surrounding code or deployment changes.
Why might a scanner miss an authorization bug?
Authorization depends on the application's actor, object, action, and business policy. A tool can recognize some framework checks and data paths, but it may not know that one tenant must not see another tenant's report or that a manager cannot approve their own transaction. Manual policy review and denied tests remain essential.
Sources and further reading
- OWASP Code Review Guide for review scope and manual technique.
- Semgrep rule ideas and Semgrep glossary for structural and taint concepts.
- CodeQL data-flow analysis and CodeQL path queries for modeled flow.
- GitHub code scanning setup types for the importance of actual scan configuration.
- GitHub supply-chain security guidance and OWASP Vulnerable Dependency Management for dependency inventory and triage.