Awesome Reviewers

Reviewer · Security

Apply security checks consistently

When a security control (authorization check, field/host allow-list, secret redaction, proxy/allowed-hosts enforcement) is added for one code path, audit every other path that performs the equivalent operation and apply the same control there too. Partial coverage is worse than no coverage because it creates a false sense of safety while leaving an...

Instruction

When a security control (authorization check, field/host allow-list, secret redaction, proxy/allowed-hosts enforcement) is added for one code path, audit every other path that performs the equivalent operation and apply the same control there too. Partial coverage is worse than no coverage because it creates a false sense of safety while leaving an identical, reachable bypass.

Concrete patterns to watch for:

  • A validation helper (e.g. assertAgentFieldsAreMapped, validateAgentKueryFields) added to one query entry point but not to a sibling function that builds the same kind of query (e.g. agent status vs. agent list).
  • A privilege requirement added to a route or feature’s “All” list that misses a request-scoped write performed deeper in the call chain (e.g. bulkUpgrade/bumpAgentPoliciesRevision using an internal client that still needs the dropped privilege).
  • A host/SSRF allow-list that blocks one bypass form (scheme://) but not another with the same effect (/path treated as a Unix socket by the driver).
  • A caller-controlled value that can still widen behavior (e.g. a data_stream.type override accepted on package types where it shouldn’t be) even after the main abuse case is closed.
  • A secondary HTTP client (e.g. a connector’s own AssumeRole/token call) built outside the shared request pipeline, bypassing proxy, TLS, and allowedHosts enforcement that every other outgoing request gets.
  • Secret/credential redaction logic that only matches one casing or one source of headers, so a differently-cased or differently-sourced duplicate leaks the secret.

When adding or fixing a security control:

  1. Identify every code path that can reach the same sensitive operation (list routes, bulk operations, internal/system clients, alternate auth types, redirects) and confirm each one goes through the same check.
  2. Prefer centralizing the check in one shared function/interceptor that all callers use, rather than duplicating it ad hoc per call site.
  3. Add a regression test for each path, not just the one originally reported, mirroring existing tests for sibling paths (e.g. status.test.ts alongside crud.ts tests).
  4. If full coverage isn’t possible in the current change (e.g. a backport without a core feature), document the remaining gap explicitly and track it as a follow-up rather than leaving it silent.

Example: a filterKuery validator was added only to getAgentsByKuery; getAgentStatusForAgentPolicy built an equivalent query but reached Elasticsearch unvalidated. The fix is to call the same assertAgentFieldsAreMapped (or equivalent allow-list check) in both places and add a matching test for the second path.