Skip to content

fix: repo review: msearch hidden wildcards, OCSF src_endpoint, OCSF bucket check, SCIM pathless remove - #306

Merged
jfcmartins merged 5 commits into
mainfrom
claude/focused-thompson-nvz50n
Nov 11, 2026
Merged

jfcmartins merged 5 commits into
mainfrom
claude/focused-thompson-nvz50n

Conversation

@jfcmartins

Copy link
Copy Markdown
Collaborator

What and why

Five small fixes from a scheduled review of the repository. I checked the open PRs (#300–#304, #276) first so this doesn't duplicate their work.

  1. search: expand_wildcards in _msearch header lines was never checked (crates/limen-worker/src/search/rules.rs).
    • Before: grant_allows refused hidden-index wildcard expansion only when the query string asked for it. Elasticsearch and OpenSearch also accept expand_wildcards in each _msearch header, so {"index":"logs-*","expand_wildcards":"all"} got past that check.
    • Now: the header value is read and treated the same as the query string. A grant that names a dot-pattern may still expand to hidden indices; a grant that doesn't is refused. A non-string value is refused (fails closed).
  2. audit/OCSF: most proxy events had no src_endpoint (crates/limen-audit/src/ocsf.rs).
    • Before: the proxy writes client_addr as SocketAddr::to_string() (203.0.113.9:51234, [2001:db8::1]:22) in limen-proxy/src/sessions.rs:126 and kube.rs. The OCSF mapper parsed only a bare IpAddr, so SSH, DB and Kubernetes session events and proxy denials lost the source IP without any warning. SIEM rules that match on source IP never fired for them.
    • Now: a socket address maps to src_endpoint.ip plus port. A bare IP gives the same output as before.
  3. config: two AWS endpoints passed the "OCSF bucket must not be the audit bucket" check (crates/limen-control-plane/src/config.rs).
    • Before: with --audit-s3-endpoint https://s3.us-east-1.amazonaws.com, an OCSF endpoint in another region and the same bucket name, the endpoints counted as "different stores". S3 bucket names are global, so both flags pointed at the one bucket that holds recordings.
    • Now: two AWS endpoints count as the same store, which is what the no-audit-endpoint arm already assumed.
  4. scim: a pathless remove on a Group replaced its members (crates/limen-control-plane/src/scim.rs, plan_patch).
    • Before: {"op":"remove","value":{"members":[{"value":"<bob>"}]}} became Step::Replace([bob]). That removed every other member and ended their logins. An unknown or missing op did the same.
    • Now: a pathless remove returns 400 noTarget (RFC 7644 §3.5.2.2), an unknown op returns 400, and add and replace behave as before.
    • Also: the Bearer scheme is now matched case-insensitively (RFC 7235 §2.1).
  5. docs: demos/README.md cited ADR-0048 (SCIM) for the OCSF demo. It now cites ADR-0049.

Related: ADR-0048, ADR-0049; no phase work.

How it was verified

  • cargo fmt --all --check: clean.
  • cargo clippy --locked -p limen-audit -p limen-worker -p limen-control-plane --all-targets --all-features -- -D warnings: clean. This covers only the crates I touched, not the whole workspace.
  • cargo test --locked -p limen-audit -p limen-worker -p limen-control-plane --lib: 39, 153 and 359 passed, 0 failed.
  • New tests (each passes):
    • search::rules::tests::msearch_headers_cannot_ask_for_hidden_indices
    • ocsf::tests::a_socket_address_becomes_an_endpoint_with_its_port
    • scim::tests::a_pathless_members_patch_needs_a_known_op
    • scim::tests::the_bearer_scheme_is_case_insensitive
    • extra cases in config::tests::ocsf_settings_cannot_share_the_audit_bucket_or_key_or_outgrow_the_spool
  • I read the existing SCIM integration tests: every remove they send has a path, so they are unaffected.

Not verified

  • Integration tests: no PostgreSQL, KMS or S3 in this environment, so tests/scim.rs, tests/ocsf_sink.rs and the e2e suite were not run.
  • No demo was run.
  • gitleaks and cargo deny were not run because mise isn't installed here. No dependencies changed.
  • The _msearch bypass is unverified against a real Elasticsearch or OpenSearch. The missing check is confirmed in code; how far a real engine's expansion reaches into hidden indices was not tested.

Review guide

Each fix is its own commit. The deeper findings below were left unfixed on purpose. Each needs a design decision or an integration test I couldn't run here:

  • SCIM adoption keeps source='idp_login' (scim.rs:412-424 together with the effective_groups! macro in console/store.rs).
    • A person who signed in before SCIM was enabled, and is later adopted by a SCIM POST, can have NULL effective groups. That happens while idp_groups is NULL, for example on an IdP whose refreshed tokens leave out the groups claim.
    • In that state, enforce skips them when they are removed from a pushed group, so their login is not ended.
    • Repeated POSTs of the same name also return 201 again, where RFC 7644 expects 409.
    • A possible fix is setting source='scim' on adoption, but that changes what the Users page shows. Owner's call.
  • SCIM group rename doesn't end logins that relied on the old name (apply_group together with effective_groups!). The old name is no longer in scim_groups, so it survives the EXCEPT. This contradicts ADR-0048.
  • SCIM deactivate: if lock_user commits the lock but its audit write fails, end_logins_of is skipped. Okta's retry then finds the person already inactive, so tracked logins are never ended. The lock still blocks access in the meantime.
  • Postgres worker: Parse, Bind and Close update the statement and portal maps before the server confirms them (db/pg.rs inspect). A rejected re-Parse of a name (42P05), or anything sent after an error before Sync, can make an Execute audit event name a statement that didn't run. The same maps can also grow without bound. The fix needs a pending queue that is committed on ParseComplete or BindComplete, which is a larger change.
  • OCSF sink (needs verification):
    • The S3 client has no operation timeout (limen-verify/src/client.rs), so a hung PUT might stall the OCSF consumer before ocsf_may_skip is ever checked.
    • A skipped batch is recorded as last_ok and counted in shipped_total.
    • --audit-ocsf-max-lag-bytes within one record of --audit-spool-max-bytes passes the config check, but then skipping can never start.

Checklist

  • Tests added or updated; cargo fmt and cargo clippy ... -D warnings clean (on the touched crates)
  • Docs updated: n/a (behavior fixes; one demos README citation fixed)
  • Phase work: n/a
  • Secrets stay out of logs; mTLS and fail-closed audit intact (no changes to those paths; the search change refuses more, never less)
  • New dependency: n/a
  • New entry point or data store: n/a
  • Commits are conventional, small and focused

Compatibility and rollback

  • A SCIM client that sends a pathless remove (or an unknown op) on Group members now gets 400 instead of a silent replace.
  • An _msearch that asks for hidden indices in a header, under a grant without a dot-pattern, is now refused.
  • A config that uses two AWS endpoints with the same bucket for audit and OCSF now fails at startup.
  • To roll back, revert the individual commit.

Generated by Claude Code

…ept any-case Bearer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYX2oXyeHMAAYugn6jg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYX2oXyeHMAAYugn6jg
@jfcmartins
jfcmartins marked this pull request as ready for review November 11, 2026 12:23
@jfcmartins
jfcmartins merged commit 8b9a889 into main Nov 11, 2026
15 checks passed
@jfcmartins
jfcmartins deleted the claude/focused-thompson-nvz50n branch November 11, 2026 12:40
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.

2 participants