Skip to content

fix: reject requests targeting a cachew playpen when not running as one#204

Merged
alecthomas merged 1 commit intomainfrom
jrobotham/playpen-guard
Mar 20, 2026
Merged

fix: reject requests targeting a cachew playpen when not running as one#204
alecthomas merged 1 commit intomainfrom
jrobotham/playpen-guard

Conversation

@jrobotham-square
Copy link
Contributor

Adds a middleware that returns 503 when a request includes a cachew-playpen baggage header but the instance is not a playpen. Prevents requests from silently falling through to staging when the target playpen is unavailable. Disabled when IS_PLAYPEN=true.

@jrobotham-square jrobotham-square changed the title Reject requests targeting a cachew playpen when not running as one fix: Reject requests targeting a cachew playpen when not running as one Mar 20, 2026
@jrobotham-square jrobotham-square changed the title fix: Reject requests targeting a cachew playpen when not running as one fix: reject requests targeting a cachew playpen when not running as one Mar 20, 2026
@jrobotham-square jrobotham-square force-pushed the jrobotham/playpen-guard branch from a87d005 to a0485ea Compare March 20, 2026 04:53
@jrobotham-square jrobotham-square marked this pull request as ready for review March 20, 2026 05:48
@jrobotham-square jrobotham-square requested a review from a team as a code owner March 20, 2026 05:48
@jrobotham-square jrobotham-square requested review from js-murph and removed request for a team March 20, 2026 05:48
@alecthomas alecthomas merged commit 2f3c5c3 into main Mar 20, 2026
7 checks passed
@alecthomas alecthomas deleted the jrobotham/playpen-guard branch March 20, 2026 08:45
@@ -0,0 +1 @@
selected_org: cash
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this?

Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

.

alecthomas added a commit that referenced this pull request Mar 20, 2026
…ning as one (#204)"

This reverts commit 2f3c5c3.

Co-authored-by: Claude Code <noreply@anthropic.com>
alecthomas added a commit that referenced this pull request Mar 20, 2026
#206)

…ning as one (#204)"

This reverts commit 2f3c5c3.

@jrobotham-square I'd prefer not to have anything bespoke in Cachew. We
have OPA enforcement now, we can add an OPA policy to do the same thing:

```hcl
opa {
  policy = <<EOF
    package cachew.authz
    
    default allow := false
    
    allow if {
        permitted
        not deny
    }
    
    permitted if input.method == "GET"
    permitted if input.method == "HEAD"
    permitted if startswith(input.remote_addr, "127.0.0.1:")
    
    deny if {
        data.IS_PLAYPEN != "true"
        contains(input.headers.baggage, "cachew-playpen=")
    }
  EOF
  data = <<EOF
    {"IS_PLAYPEN": "${IS_PLAYPEN}"}
  EOF
}
```


We can extend the OPA integration to support returning a message or a
different HTTP status if required.

Co-authored-by: Claude Code <noreply@anthropic.com>
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