Skip to content

fix: no usernames in Otel - #1063

Closed
HatemMn wants to merge 6 commits into
developfrom
fix/restrict_audit_info
Closed

fix: no usernames in Otel#1063
HatemMn wants to merge 6 commits into
developfrom
fix/restrict_audit_info

Conversation

@HatemMn

@HatemMn HatemMn commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Audit should not expose usernames

Merge this after this one to close subissue : #934

@HatemMn HatemMn linked an issue Jul 15, 2026 that may be closed by this pull request
@HatemMn HatemMn self-assigned this Jul 15, 2026
@HatemMn
HatemMn force-pushed the fix/restrict_audit_info branch from c69f82a to 110992b Compare July 21, 2026 10:28

@HatemMn HatemMn left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review from last-KMS-tester-v5

Ran the full verification pass on this branch's diff (fa263b1b..HEAD, 4 files / 151 lines) — the fix hashes the user OTEL metric label with SHA-256 instead of exporting the raw username.

PR Finding Report — fix/restrict_audit_info

Scope: otel_metrics.rs, Cargo.toml, Cargo.lock, OTLP_METRICS.md
What changed: bounded_user_label() now returns hash_user(user) (truncated SHA-256, 16 hex chars) instead of the raw username, for the kms.kmip.operations.per_user.total and kms.permissions.granted.per_user.total labels. Docs updated to match.

Verification performed

Check Result
cargo test -p cosmian_kms_server --lib core::otel_metrics PASS — 13/13, including the 2 updated + 2 new tests (test_user_label_hash_is_deterministic, test_user_label_overflow_stays_literal_sentinel)
cargo clippy -p cosmian_kms_server --lib --all-targets -- -D warnings PASS — zero warnings
Grep for other raw-username export paths (KeyValue::new("user", other /metrics routes) CLEAN — the only two call sites already go through bounded_user_label; active_users_tracker (raw usernames) is never read into a KeyValue, only used internally for cardinality/dedup bookkeeping
Cardinality-cap interaction (contains_key check uses raw key, hash only applied to the label) Correct — the dedup logic and the hashing are independent concerns and don't interfere
Truncation safety (.get(..16) on a 64-char hex string) Safe, follows the repo's clippy::indexing_slicing convention (.get() + unwrap_or fallback, never panics even if the constant were misconfigured)
Doc/code consistency Markdown table reformatting is just prettier/mdformat noise; the substantive note about hashing matches the code

Regression check

kms.active.users (the unique-active-user gauge) counts tracker entries only, never labels — unaffected by the hash change. No adjacent behavior touched.

One non-blocking finding

The doc/comment claims the hash is "non-reversible." That's true against an unknown input space, but usernames here are typically emails/OAuth subjects — a low-entropy, guessable space. Anyone with a candidate identity list can hash each candidate and match against exported labels (dictionary attack), so this is pseudonymization, not strong de-identification. Not a regression from this PR's stated goal (raw usernames no longer appear verbatim in the OTLP backend), but worth knowing if the threat model requires resistance against a motivated insider with a user list. If that matters, consider HMAC-SHA256 with a server-side secret instead of a plain hash.

Verdict: GO — small, well-tested, no regressions found; the reversibility caveat above is worth a follow-up note but doesn't block this fix.

@HatemMn
HatemMn requested a review from Manuthor July 21, 2026 11:08
@HatemMn HatemMn removed their assignment Jul 21, 2026
@HatemMn
HatemMn force-pushed the fix/restrict_audit_info branch from 07063ed to 1b6a40d Compare July 21, 2026 11:11
@HatemMn HatemMn changed the title fix: audit info fix: no usernames in Otel Jul 21, 2026
HatemMn added 6 commits July 23, 2026 16:43
fix: fixes

fix: commit

fix: manual edits

fix: another fix
feat: WIP on feat/audit_and_siem

chore: adr

feat: fix the limits

doc: doc is hard

test: integration
feat: fix final flaws

feat: fix tests that didn't pass

fix: ci fix

feat: 2

feat: ci

fear: update reverse proxy docs

fix: iris

fix: another fix

fix: restaure iris
@HatemMn
HatemMn force-pushed the fix/restrict_audit_info branch from 1b6a40d to d964938 Compare July 23, 2026 14:56
@HatemMn

HatemMn commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

I'm sick of solving this merge commit I will open a new PR

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