Skip to content

fix: identity attribute bypass, REST panic recovery, etcd key injection, MongoDB watch idle, and more#44

Merged
caiwl merged 1 commit into
masterfrom
caiwl/bugs/round4-hardening
Jun 24, 2026
Merged

fix: identity attribute bypass, REST panic recovery, etcd key injection, MongoDB watch idle, and more#44
caiwl merged 1 commit into
masterfrom
caiwl/bugs/round4-hardening

Conversation

@caiwl

@caiwl caiwl commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Round 4 Hardening — Security & Correctness

Fixes from the latest 3-agent review sweep:

High

  • H1: Identity attribute override — request_user/request_groups/request_entity now re-asserted after user-attribute merge (was only resource/action/time). Prevents auth bypass via Attributes:{"request_user":"admin"}.
  • H3: REST panic recovery — added HTTPPanicRecoveryMiddleware to both REST routers (was gRPC-only). Plus nil guard in IsSubSet to prevent reflect.TypeOf(nil).Kind() panic.
  • H6: etcd key injection — added validateID for policy/rolePolicy IDs + validateServiceName on all missing read/list/delete methods. Prevents id="../../functions/victim" traversal.

Medium

  • C1: MongoDB watch idle timeout — changeStream.Next() returning false on deadline expiry now retries instead of exiting. Was breaking incremental cache updates after 30s idle.
  • C3: REST Discover error handling — returns HTTP error on failure instead of 200 + allowed:true.
  • M1: etcd discover serviceName validation in PutRequest/Get*/Reset*.

Low / Quality

  • L2: Asserter webhook response body limited to 1MB (was unbounded).
  • Q1: speedleError.Unwrap() added for stdlib errors.Is/errors.As compatibility.

🤖 Generated with Claude Code

…uard, etcd key injection, MongoDB watch idle, Discover error handling, asserter body limit, errors.Unwrap, discover serviceName validation

H1: Re-assert request_user/request_groups/request_entity after user-attribute
    merge to prevent authorization bypass via injected identity attributes.
H3: Add HTTPPanicRecoveryMiddleware to both REST routers (was gRPC-only).
    Add nil guard to IsSubSet to prevent reflect.TypeOf(nil).Kind() panic.
H6: Add validateID for policy/rolePolicy IDs; add validateServiceName to all
    missing etcd read/list/delete methods. Prevents etcd key injection via
    crafted IDs containing '/' (e.g. '../../functions/victim').
C1: MongoDB watch no longer exits on idle timeout — distinguishes deadline
    expiry (retry) from genuine stream error (exit). Fixes broken incremental
    cache updates after 30s of no policy changes.
C3: REST Discover handler now returns HTTP error on evaluation failure
    instead of HTTP 200 with allowed:true.
M1: Validate serviceName in etcd discover PutRequest/Get*/Reset* methods.
L2: Add 1MB body limit to asserter webhook response (was unbounded).
Q1: Add Unwrap() to speedleError for stdlib errors.Is/As compatibility.

Co-Authored-By: Claude <noreply@anthropic.com>
@caiwl caiwl merged commit 73dbecb into master Jun 24, 2026
9 checks passed
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