MSBA-361 · Lesson 3 of 12 · 18 min

Reading code scanning alerts

▶ Video coming soon A video version of this lesson is on the way.

By the third Thursday, every group at Skerry had alerts and most had opinions about them. Teodric Nnaji-Lund from the commerce group arrived with a printout of one alert from the checkout service and a single question written across the top: is this real? Seraphine said that was exactly the right question, and that the alert page was designed to answer it, if you knew how to read it.

This lesson walks through a code scanning alert from top to bottom, then covers the life of an alert from detection to closure, and the triage habits that keep a large backlog manageable.

The parts of an alert

Every code scanning alert has the same structure, whether it came from CodeQL or a third-party tool.

A mock-up of an alert page divided into labeled regions: title and rule ID at the top, severity and security severity badges, affected branches, the code location with highlighted line, a show paths link for data flow, the rule help text, tags such as CWE identifiers, and a timeline of events at the bottom.
The regions of a code scanning alert page.
What each part of an alert page is for.
PartWhat it tells you
Title and ruleWhich query or rule fired, for example a CodeQL query for database queries built from user-controlled sources
ToolWhich analysis produced it: CodeQL, or the name of a third-party tool
Severity and security severityHow serious the finding is as an error, warning or note, and for security rules whether it is critical, high, medium or low
TagsClassification such as security, correctness and the CWE identifiers
LocationThe file and lines where the problem is reported, with the code shown
Show pathsFor data flow alerts, each step from source to sink
Rule helpAn explanation of the problem, how to fix it, examples and references
Affected branchesWhich branches currently contain the alert
TimelineWhen it was first detected, in which commit, and every state change since

Following the path

Teodric's alert was a data flow alert for cross-site scripting in the checkout service's order confirmation page. The location pointed at a line that wrote a value into the page. On its own, the line looked harmless. The show paths view told the rest of the story: the value began as a query parameter carrying a gift message, passed through three functions in two files, was stored briefly on the order object and was then inserted into the page without escaping.

A vertical list of five steps in a data flow path: step one, request query parameter gift message (source); step two, passed to buildOrderSummary; step three, assigned to order summary field; step four, read in renderConfirmation; step five, inserted into page HTML (sink). Step five is highlighted.
The path view for Teodric's alert, from query parameter to page.

Reading a path well means asking three questions at each step. Could an attacker control this value? Does anything on this step make it safe for the sink at the end? Is the path actually reachable when the application runs? In Teodric's case the answers were yes, no and yes. The gift message could contain anything a shopper typed, nothing escaped it, and the confirmation page was shown to every shopper. The alert was real.

Some paths fail the third question. CodeQL sometimes finds paths through code that is only reachable in tests, behind a feature flag that is permanently off, or through an unusual combination of configuration that cannot occur in production. Those are candidates for dismissal, with a note saying why, but only after someone has checked.

Severity and security severity together

Freya's team agreed a simple reading of the two severity fields for Skerry.

Skerry's response targets by security severity. Targets are Skerry's own policy, not GitHub defaults.
Security severitySkerry response target on production codeMerge behavior after lesson 11's ruleset
CriticalFix within 7 daysBlocks merge
HighFix within 30 daysBlocks merge
MediumFix within 90 days or in a campaignWarns
LowFix when the code is next changedWarns
None (quality rules: error, warning, note)Team discretionDoes not block

Response targets like these are the organization's decision, not something GitHub sets. GitHub provides the classification and the tools to filter and enforce; the security team decides what each level means for its own risk.

The life of an alert

An alert is created when an analysis first reports a problem on a branch that GitHub tracks. From then on it moves through a small set of states.

Alert states and how they change.
StateHow it happensNotes
OpenAn analysis reports the problemShown in lists and counted in metrics
FixedA later analysis of the same branch and category no longer reports itClosed automatically; nobody clicks fixed
Dismissed: false positiveA person decides the alert is wrongShould include a comment saying why
Dismissed: won't fixA person accepts the risk or the code is being retiredShould name who accepted the risk
Dismissed: used in testsThe code is test-onlyBetter handled by excluding test paths where possible
ReopenedA person reopens a dismissed alert, or a fixed problem reappearsKeeps the alert's history

The point that surprises new users most is that fixed is automatic. Code scanning closes an alert as fixed only when a new analysis of the same branch and category no longer reports it. Developers do not mark alerts as fixed by hand. If a developer merges a change that ought to fix an alert and the alert stays open, either the analysis has not run yet, or the change did not remove the path CodeQL found.

Dismissal, by contrast, is a human decision. It should be rare and explained. GitHub records who dismissed the alert, when, with which reason and comment, and the timeline keeps that record even if the alert is later reopened. Ottoline Brisbane-Teale, Skerry's internal audit lead, had already said that the January 2027 audit would sample dismissed alerts and expect a comment on every one.

Who can dismiss

By default, people with write access to a repository can dismiss its code scanning alerts. In organizations that want more control, GitHub supports delegated alert dismissal for code scanning: developers request a dismissal with a reason, and a designated reviewer, usually from the security team, approves or rejects it. Skerry turned this on through the Stores restricted configuration for skerry-stores, where alerts in payment terminal code needed a second opinion before anyone dismissed them. Lesson 9 covers the roles involved.

Branches, pull requests and categories

Alerts are tracked per branch. An alert on the default branch is the one that counts in most metrics. A pull request shows alerts that the change introduces compared with its base branch; when the pull request is merged and the default branch is analyzed again, those alerts either appear on the default branch or, if they were fixed before merging, never do.

Each analysis also has a category. Results from different categories are tracked separately, so the checkout monorepo's three analyses (front end, order services and pricing) each manage their own alerts. If a team changes a workflow so that the category changes, old alerts may remain open under the old category and look stale. The fix is to keep categories stable, or to delete the old analysis from the code scanning settings once the new one is running.

Filtering a large list

The alert list for a repository, and security overview across many, supports filters that make thousands of alerts workable. Seraphine showed the filters her team used every day.

Common filters on the code scanning alert list. Exact filter names can change; use the filter picker.
FilterExampleUse
Stateis:openHide fixed and dismissed alerts
Tooltool:CodeQLSeparate CodeQL from third-party results
Severityseverity:critical,highStart with the most serious
Rulerule:js/xssFind every instance of one pattern
Branchbranch:mainFocus on the default branch
Tagtag:securityExclude quality-only findings
Application code onlyThe filter that hides alerts in test, generated and documentation codeCut noise from code that does not ship
Autofix availableThe filter for alerts with a suggested fixFind quick wins

Filtering by rule is the habit that turns a backlog into a plan. Of the commerce group's 1,180 open alerts, 410 came from just four rules. Fixing a rule's pattern once, for example by adding a shared escaping helper, and then applying it everywhere, is far quicker than handling alerts one by one. Lesson 7 shows how security campaigns build on exactly this idea.

A triage routine

The team settled on a routine for each repository's first pass.

A first-pass triage routine for one repository.
StepActionOutcome
1Filter to open security alerts in application code on the default branchThe list that matters
2Sort by security severity and group by rulePatterns, not individual alerts
3Read one alert per rule fully, including the pathDecide whether the rule is finding real problems here
4If real, fix one instance and apply the pattern to the restEfficient remediation
5If not real, dismiss with a comment, and consider excluding the path or tuning the queryLess noise next time
6Assign remaining alerts to owners with a due dateAccountability

Code scanning alerts can be assigned to a person with write access, which shows ownership on the alert and appears in filters and the API. Skerry used assignment for anything not fixed within a week of triage, so that security overview could show who owned what.

Worked problem

Is this alert real?

A high security severity alert reports a path traversal in an inventory export job: a file name from a message queue is joined to a directory and opened. The path view shows the source is a queue message. The team says the queue is internal, so the alert is a false positive. What should the reviewer check before agreeing?

Show solution
  1. Who can publish to the queue: only trusted services, or any service in the network?
  2. Whether the file name is validated anywhere on the path, for example against an allow list.
  3. Whether the job runs with access to sensitive directories.
  4. If publishers are not tightly controlled or validation is missing, treat the alert as real.

Answer: An internal source is not automatically trusted. Unless publishing to the queue is restricted and the name is validated, fix the alert with validation rather than dismissing it.

Teodric fixed his cross-site scripting alert by escaping the gift message with the framework's standard output encoding rather than building the HTML by hand. The next pull request scan reported nothing on that path, and after merge the default branch analysis closed the alert as fixed. He brought the second printout, showing the closed alert, to the following week's session.

Writing a dismissal comment someone can use

A dismissal without a comment saves a minute today and costs an hour in six months, when an auditor or a new team member asks why a serious alert was closed. Skerry's guidance asked for three things in every dismissal comment for high and critical alerts: what makes the alert not a problem, where that is enforced, and what would make the decision wrong.

Dismissal comments that will still make sense later.
Weak commentUseful comment
Not exploitableThe id parameter is converted to an integer by the route definition before this query runs; if the route changes to accept strings, reopen
Test codeFile is under tests and builds only into the test target; the test fixture deliberately uses unsafe input
Fixed elsewhereInput is validated by the gateway allow list for this path; see the gateway configuration; this service is not reachable directly

The third part of the comment, what would make the decision wrong, was the one developers found hardest and auditors found most valuable. It turns a dismissal into a small, testable claim. When Ottoline sampled dismissals in her November review, she could check the claim against the current code, and two of the dismissals she sampled no longer held because the code had changed. Both alerts were reopened and fixed.

An alert closed as fixed can also reopen on its own. If a later commit reintroduces the same problem at the same location, code scanning matches it to the original alert and reopens it, which keeps the history together. A developer who sees a reopened alert should read its history before acting, because the earlier fix or dismissal often explains what changed.

Common mistakes

  • MistakeJudging an alert by the highlighted line alone.

    InsteadOpen the path view and check each step from source to sink.

  • MistakeTrying to mark an alert as fixed.

    InsteadFix the code; the next analysis closes the alert automatically.

  • MistakeDismissing alerts without a comment.

    InsteadRecord the reason, the evidence and who accepted any risk.

  • MistakeTreating internal sources as trusted by default.

    InsteadCheck who can control the data and whether it is validated.

  • MistakeChanging an analysis category without cleaning up.

    InsteadKeep categories stable, or delete the old analysis once the new one runs.

Summary and key terms

  • An alert page shows the rule, tool, severities, tags, location, data flow path, rule help, branches and timeline.
  • For data flow alerts, check each step for attacker control, sanitization and reachability.
  • Alerts are open, fixed, dismissed or reopened; fixed is set automatically by a later analysis.
  • Dismissal is a recorded human decision with a reason and should always carry a comment.
  • Delegated alert dismissal lets security reviewers approve dismissals.
  • Alerts are tracked per branch and per analysis category.
  • Filtering by severity, rule and application code turns a large backlog into patterns that can be fixed together.
Show paths
The view of a data flow alert that lists each step from source to sink.
Dismissed
An alert state set by a person, with a reason such as false positive, won't fix or used in tests.
Fixed
An alert state set automatically when a later analysis no longer reports the problem.
Delegated alert dismissal
A setting that requires dismissal requests to be approved by designated reviewers.
Affected branches
The branches on which an alert is currently present.
Alert assignee
A person with write access assigned to own an alert.
Rule help
The explanation, guidance and examples attached to the rule that produced an alert.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. A developer merged a fix but the alert is still open an hour later. Name two possible reasons.

    Show answer

    The default branch analysis has not run yet, or the change did not remove the path the query found.

  2. Which dismissal reason fits code that only runs in automated tests?

    Show answer

    Used in tests, though excluding test paths from analysis is often better.

  3. Why filter by rule during triage?

    Show answer

    Repeated alerts from one rule can usually be fixed with one pattern applied everywhere.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz