Skip to content

Record the series key by id in audit metadata, not by name - #108

Merged
leowilkin merged 1 commit into
mainfrom
series-api-audit-metadata
Sep 3, 2026
Merged

Record the series key by id in audit metadata, not by name#108
leowilkin merged 1 commit into
mainfrom
series-api-audit-metadata

Conversation

@leowilkin

Copy link
Copy Markdown
Member

Follow-up to #106.

CodeQL flagged the Series API's audit write as clear-text storage of sensitive data (rb/clear-text-storage-sensitive-data, high). It traces the read of name off a series API token into audit_logs.metadata, which is a plain jsonb column. The alert appeared on #106 but CodeQL is not a required check, so auto-merge landed the PR before it was addressed.

The name was never a secret — it is the display label built from the creator's email local part, and the secret itself is only ever held as a SHA256 digest. So this is not a leak. But the metadata does not need the label, and storing the key's id instead:

  • removes the flagged dataflow entirely, rather than dismissing the alert
  • survives a rename or a rotation
  • resolves to the key's name, creator and revocation state, since revoking keeps the row

Distinct from the ~14 pre-existing alerts under the same rule, which are the known Active Record encrypts blindness (CodeQL cannot see that date_of_birth, medical_text and friends are encrypted at rest). Those are genuine false positives; this one was better fixed than dismissed.

Spec updated to assert the id. 41 series specs green, rubocop clean.

CodeQL flagged the Series API's audit write as clear-text storage of
sensitive data (rb/clear-text-storage-sensitive-data, high): it traces the
read of `name` off a series API token into audit_logs.metadata, which is a
plain jsonb column.

The name was never a secret -- it is the display label built from the
creator's email local part, and the secret itself is only ever held as a
SHA256 digest. But the metadata does not need the label: storing the key's id
instead removes the flagged dataflow entirely and is more useful to an
auditor, since an id survives a rename or a rotation, resolves to the key's
name, creator and revocation state, and revoking a key keeps its row.
@leowilkin
leowilkin enabled auto-merge (squash) September 3, 2026 20:52
@leowilkin
leowilkin merged commit 8747618 into main Sep 3, 2026
13 of 14 checks passed
@leowilkin
leowilkin deleted the series-api-audit-metadata branch September 4, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant