Skip to content

Address security review findings (SEC-1266)#1

Open
sergical wants to merge 9 commits intomainfrom
sec-1266/security-review
Open

Address security review findings (SEC-1266)#1
sergical wants to merge 9 commits intomainfrom
sec-1266/security-review

Conversation

@sergical
Copy link
Copy Markdown
Member

@sergical sergical commented Apr 7, 2026

Summary

  • Validate API key format (trim whitespace, reject < 8 chars)
  • Add regex validation to dateRangeSchema for known Plausible date formats
  • Sanitize error messages: return HTTP status code only, raw API bodies stay in Sentry
  • Validate baseUrl is HTTPS to prevent SSRF
  • Add max(1024) length bounds to page/goal filter schemas
  • Add Cache-Control: no-store and X-Content-Type-Options: nosniff headers
  • Add Cloudflare rate limiting (60 req/min per IP)

Test plan

  • bun run build passes
  • bun run test — all 53 tests pass
  • Deploy to staging and verify rate limiting returns 429 after threshold
  • Verify invalid baseUrl throws at construction time
  • Verify whitespace-only API key returns 401

Addresses SEC-1266

🤖 Generated with Claude Code

sergical and others added 2 commits April 7, 2026 09:53
- Validate API key format (trim whitespace, reject < 8 chars)
- Add regex validation to dateRangeSchema for known formats
- Sanitize error messages: return status code only, not raw API bodies
- Validate baseUrl is HTTPS to prevent SSRF
- Add max length (1024) to page/goal filter schemas
- Add Cache-Control: no-store and X-Content-Type-Options: nosniff headers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Uses Cloudflare Rate Limiting binding to throttle requests by
CF-Connecting-IP. Fails open if binding unavailable (dev mode).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 7, 2026

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Date range regex rejects valid Plausible 24h value
    • Added \d+h to dateRangeSchema regex and updated schema messages to include 24h.

Create PR

Or push these changes by commenting:

@cursor push 38b2b6d6c2
Preview (38b2b6d6c2)
diff --git a/src/schemas.ts b/src/schemas.ts
--- a/src/schemas.ts
+++ b/src/schemas.ts
@@ -58,11 +58,11 @@
 export const dateRangeSchema = z
   .string()
   .regex(
-    /^(\d+d|\d+mo|day|month|year|all|\d{4}-\d{2}-\d{2},\d{4}-\d{2}-\d{2})$/,
-    'Must be "Nd", "Nmo", "day", "month", "year", "all", or "YYYY-MM-DD,YYYY-MM-DD"'
+    /^(\d+d|\d+h|\d+mo|day|month|year|all|\d{4}-\d{2}-\d{2},\d{4}-\d{2}-\d{2})$/,
+    'Must be "Nd", "Nh", "Nmo", "day", "month", "year", "all", or "YYYY-MM-DD,YYYY-MM-DD"'
   )
   .describe(
-    'Date range: "7d", "30d", "12mo", "month", "year", "all", or "YYYY-MM-DD,YYYY-MM-DD"'
+    'Date range: "24h", "7d", "30d", "12mo", "month", "year", "all", or "YYYY-MM-DD,YYYY-MM-DD"'
   );
 
 export const pageSchema = z

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

sergical and others added 3 commits April 7, 2026 10:04
Addresses Bugbot review: the regex was missing \d+h for
Plausible's supported hourly date range format.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deploy script now reads version from package.json instead of git SHA,
aligning Sentry releases with semver tags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sets up getsentry/craft for GitHub releases with semver versioning.
Trigger via Actions > Release > Run workflow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes bugbot review: period_a and period_b were using bare z.string()
instead of the validated dateRangeSchema, bypassing format checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes bugbot review: short keys now get "Invalid API key. Key is too
short." instead of the misleading "Missing" message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 878909e. Configure here.

sergical and others added 2 commits April 7, 2026 11:21
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wrap createServer in try/catch so a misconfigured baseUrl returns a
proper 500 JSON response instead of crashing every request.

Co-Authored-By: Claude Opus 4.6 (1M context) <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.

1 participant