Skip to content

🛡️ Sentinel: [HIGH] Fix CORS wildcard credentials vulnerability#92

Open
mattjoyce wants to merge 1 commit into
mainfrom
sentinel-cors-wildcard-credentials-16077443379988911092
Open

🛡️ Sentinel: [HIGH] Fix CORS wildcard credentials vulnerability#92
mattjoyce wants to merge 1 commit into
mainfrom
sentinel-cors-wildcard-credentials-16077443379988911092

Conversation

@mattjoyce
Copy link
Copy Markdown
Owner

@mattjoyce mattjoyce commented May 21, 2026

🚨 Severity: HIGH
💡 Vulnerability: The API server's CORS configuration allowed the wildcard * in AllowedOrigins while simultaneously setting Access-Control-Allow-Credentials: true.
🎯 Impact: This is a significant security risk because it attempts to allow any website to make authenticated cross-origin requests, potentially exposing sensitive data or actions to unauthorized domains. While modern browsers block this specific combination, misconfigured or non-standard clients might still exploit it, and it represents a fundamentally insecure server posture.
🔧 Fix: Updated corsMiddleware in internal/api/server.go. When the wildcard * is present in the allowedOrigins list, the middleware now explicitly sets Access-Control-Allow-Origin: * and forces Access-Control-Allow-Credentials: false. For explicitly listed origins (no wildcard), the behavior remains intact: the specific origin is allowed and credentials are permitted.
✅ Verification: Tested the internal/api package via go test -v ./internal/api/... which successfully ran the integration tests.


PR created automatically by Jules for task 16077443379988911092 started by @mattjoyce

Summary by CodeRabbit

  • Bug Fixes

    • Improved CORS (Cross-Origin Resource Sharing) configuration handling to ensure secure credential management when wildcard origins are used.
  • Documentation

    • Added guidance on CORS security vulnerability prevention.

Review Change Stack

…ng wildcard

- Detected that when `AllowedOrigins` includes the wildcard `*`, the server was incorrectly returning `Access-Control-Allow-Credentials: true` alongside `Access-Control-Allow-Origin: *`.
- This is a significant security risk (and violates the CORS specification that modern browsers enforce), as it theoretically allows any domain to perform cross-origin authenticated requests.
- Updated `corsMiddleware` in `internal/api/server.go` to explicitly set `Access-Control-Allow-Credentials: false` when `allowAll` (`*`) is enabled. Exact origin matches continue to permit credentials.

Co-authored-by: mattjoyce <278869+mattjoyce@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3b240d44-5b34-4b06-bdef-8c8f6b857629

📥 Commits

Reviewing files that changed from the base of the PR and between b4d00cc and 3d0409e.

📒 Files selected for processing (2)
  • .jules/sentinel.md
  • internal/api/server.go

📝 Walkthrough

Walkthrough

This PR addresses a CORS security issue by detecting wildcard origins in the allowlist and conditionally disabling credentials. The middleware now sets Access-Control-Allow-Credentials: false when using Access-Control-Allow-Origin: *, preventing a security misconfiguration while maintaining per-origin credential support for specific origins.

Changes

CORS Wildcard and Credentials Fix

Layer / File(s) Summary
Security pattern documentation
.jules/sentinel.md
New sentinel entry documents the insecure CORS pattern of combining wildcard origins with allowed credentials.
CORS middleware wildcard and credentials handling
internal/api/server.go
corsMiddleware introduces an allowAll flag when allowedOrigins contains "*", then uses this flag to conditionally set Access-Control-Allow-Credentials: false and Access-Control-Allow-Origin: *, or else echo the request Origin with credentials enabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A wildcard in origins, credentials so free—
Not secure, dear reviewer, as you will see!
But this change makes it safe with a flag and a choice,
Credentials disabled when stars get a voice. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: fixing a CORS wildcard credentials vulnerability in the API server by updating the corsMiddleware logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel-cors-wildcard-credentials-16077443379988911092

Comment @coderabbitai help to get the list of available commands and usage tips.

mattjoyce added a commit that referenced this pull request Jun 6, 2026
Pure resolver (config -> ResolvedWorker, fail-closed on undefined grant) and a
pure credential builder kept separate from the Setpgid lifecycle (Hickey A1).
Threaded through the executor and spawnPlugin; unconfined is a no-op, a confined
worker on a non-Unix platform fails the spawn closed. Unit-tested on darwin; the
privileged EACCES wall test is linux+root-gated and validated on the Dell host.
mattjoyce added a commit that referenced this pull request Jun 6, 2026
mattjoyce added a commit that referenced this pull request Jun 6, 2026
…#92)

Validated on a privileged Linux host (Dell, root golang:1.25 container): the
dropped worker gets EACCES on the 0600 age key. t.TempDir nests under 0700 root
parents the worker can't traverse, so the probe never ran; a single 0755 dir
under /tmp fixes it. Wall test now PASS on privilege, skips cleanly elsewhere.
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