Skip to content

fix(security): close open findings from 2026-06-19 review (gateway auth, booking-engine price, SSRF, guest scope, +)#126

Merged
telivity-otaip merged 5 commits into
mainfrom
claude/security-hardening-2026-06-19
Jun 19, 2026
Merged

fix(security): close open findings from 2026-06-19 review (gateway auth, booking-engine price, SSRF, guest scope, +)#126
telivity-otaip merged 5 commits into
mainfrom
claude/security-hardening-2026-06-19

Conversation

@telivity-otaip

Copy link
Copy Markdown
Collaborator

Summary

Closes the open findings from the 2026-06-19 dual security review (Claude + Codex) against origin/main. The earlier CRITICALs #2/#3 were already fixed (#118#120); this PR closes the remaining exposed surface — led by the unauthenticated ChatGPT gateway (CRITICAL) and a new booking-engine price-manipulation bug (HIGH).

All changes are TDD (test written first, watched fail, then pass). 1005/1005 API tests + 19/19 gateway tests pass; typecheck clean.

Fixes

  • CRITICAL — Gateway caller-auth (tools/haip-connect-gpt): onRequest hook requires Authorization: Bearer <key> or x-api-key (timing-safe), fail-closed. /health, /openapi.json, /privacy, landing stay public. Config: GATEWAY_API_KEY (+ GATEWAY_ALLOW_PUBLIC=true opt-out for the demo).
  • HIGH — Booking-engine price-pairing: quote/book reject a rate plan whose roomTypeId ≠ the requested room type (was bookable at a cheaper room's rate with just the publishable key).
  • HIGH — Guest merge-by-email scoped: Connect + OTA findOrCreateGuest only reuse a guest already linked to the requesting property; else create a fresh row (cross-tenant PII leak/poison).
  • HIGH — Channel baseUrl SSRF: assertSafeChannelEndpoint blocks private/metadata hosts in production (opt-out CHANNEL_ALLOW_PRIVATE_ENDPOINTS for local mocks); redirect:'manual' on adapter + webhook-delivery fetches.
  • HIGH — Webhook subscription secret no longer returned in create/list responses.
  • MED — Reports RBAC: @RequirePermissions('reports.view').
  • MED — SMS per-property quota (toll-fraud/spam guard); tunable via SMS_RATE_LIMIT_MAX/_WINDOW_MS.
  • LOW — OTA confirmation numbers now use the CSPRNG token (was Date.now()+Math.random()).
  • LOW — Swagger /docs gated out of production (SWAGGER_ENABLED=true to opt in); assert-secure-config now also enforces for staging.
  • render.yaml: loud DEMO-ONLY warning (auth-off blueprint intentionally left functional).

Deploy note

The gateway fix requires GATEWAY_API_KEY set in Vercel and in the ChatGPT Action's auth config — or GATEWAY_ALLOW_PUBLIC=true to keep the public demo open.

🤖 Generated with Claude Code

telivity-otaip and others added 5 commits June 19, 2026 13:13
…cope guest reuse by property

- booking-engine quote/book: reject rate plan whose roomTypeId != requested roomType
  (price manipulation via independently-sellable room/rate ids)
- connect-events: never return the HMAC subscription secret in create/list responses
- connect + OTA inbound findOrCreateGuest: only reuse a guest already linked to the
  requesting property; otherwise create a fresh row (cross-tenant PII leak/poison)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…follow

- assertSafeChannelEndpoint(): block private/internal/metadata hosts for tenant-supplied
  channel baseUrl in production (opt-out CHANNEL_ALLOW_PRIVATE_ENDPOINTS for local mocks)
- wire into booking-com / expedia / siteminder adapter fetch paths
- redirect:'manual' on adapter + webhook-delivery fetches so a 302 to an internal host
  cannot bypass the pre-flight URL validation

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ion numbers

- reports.controller: @RequirePermissions('reports.view') so financial/occupancy
  reports aren't readable by any authenticated property user (e.g. housekeeping)
- OTA inbound generateConfirmationNumber: reuse the 128-bit CSPRNG token instead of
  Date.now()+Math.random() (was enumerable; confirmation # is a bearer credential)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The gateway injects HAIP's privileged platform Connect key on every upstream
call, so an unauthenticated public gateway is an open door to cross-tenant
Connect operations. Add an onRequest hook that requires a caller credential
(Authorization: Bearer <key> or x-api-key) on all action routes; /health,
/openapi.json, /privacy and the landing page stay public. Fail-closed: if no
GATEWAY_API_KEY is configured and GATEWAY_ALLOW_PUBLIC!=true, action routes 401.
Timing-safe comparison. Wired in server.ts + api/index.ts; documented in .env.example.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ger in prod, demo warning

- notifications: in-memory per-property SMS quota (toll-fraud/spam guard on the
  free-form, billable SMS endpoint); tunable via SMS_RATE_LIMIT_MAX/WINDOW_MS
- assert-secure-config: enforce for 'staging' too (not just 'production') so a
  staging host can't silently boot with AUTH_ENABLED=false
- main.ts: only mount Swagger /docs outside production (opt back in with SWAGGER_ENABLED=true)
- render.yaml: loud DEMO-ONLY warning — auth-off blueprint is not a production template

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@telivity-otaip telivity-otaip merged commit 295da78 into main Jun 19, 2026
4 checks passed
telivity-otaip added a commit that referenced this pull request Jun 20, 2026
…il-open on bad config (#130)

Independent codex review of #126-#128 found two gaps:
- assertSafeChannelEndpoint only enforced for NODE_ENV=production, leaving staging
  open to SSRF even though this changeset hardened staging elsewhere. Now enforces
  for production OR staging (matches assertSecureConfig).
- SMS quota parsed env with Number() and disabled on NaN, so SMS_RATE_LIMIT_MAX=garbage
  silently turned the limiter off. Now an invalid value falls back to the default
  (limiter stays on); only an explicit valid value <= 0 disables it.

Co-authored-by: Claude Opus 4.8 <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