System: Travel Reservation & Payment Platform Review Scope: Authorization, Database Security, Serverless APIs, Payments, Money Handling, Secrets Reviewer: Julius Pratt Document Type: Illustrative Sample Report
The reviewed application uses a modern architecture consisting of React/TypeScript, Supabase/PostgreSQL, serverless backend functions, and a third-party payment processor.
The review identified several areas that should be addressed before production launch.
The most important risks relate to:
| Severity | Findings |
|---|---|
| Critical | 0 |
| High | 4 |
| Medium | 3 |
| Low | 2 |
| Informational | 2 |
The system should not process live customer payments until all High-severity findings are resolved and verified.
Severity: High Category: Authorization
One backend endpoint accepts a user role supplied in the request body.
Example:
{
"reservationId": "...",
"role": "manager"
}
The endpoint uses that role to decide whether a sensitive operation is allowed.
Any value originating from the browser must be considered untrusted.
An authenticated lower-privilege user could alter the request and submit:
role = "manager"
to attempt an action intended only for elevated staff.
Determine authorization using trusted server-side identity.
The endpoint should:
Do not trust:
when supplied directly by the client.
Attempt the request while authenticated as each role and manually alter every authorization-related property.
Severity: High Category: Supabase / PostgreSQL
A policy on the trip_guests table grants SELECT access when a user belongs to the same organization.
Conceptually:
organization_id = current_user_organization()
However, some users should only have access to assigned trips rather than every trip inside the organization.
A staff member may be able to enumerate guests for trips unrelated to their assigned work.
This may expose:
Align the policy with the actual business authorization model.
Instead of checking organization membership alone, require a valid relationship between:
authenticated user
→ staff assignment
→ trip
→ guest
Where possible, authorization rules should live in PostgreSQL rather than depending on filtering performed in React.
Create:
Test all cross-organization and cross-trip combinations.
Severity: High Category: PostgreSQL
A privileged PostgreSQL function executes as SECURITY DEFINER without an explicitly fixed search_path.
Privileged functions require additional protection because they run with the function owner's permissions.
An unsafe search path can increase the risk of unexpected object resolution or privilege escalation.
Explicitly specify a controlled search path.
Example:
CREATE OR REPLACE FUNCTION ...
SECURITY DEFINER
SET search_path = public, pg_temp
AS ```math-display
[Formula]
```;
Also review:
SECURITY DEFINER is actually requiredIf elevated execution is unnecessary, convert the function to SECURITY INVOKER.
Severity: High Category: Payments
The payment endpoint creates a provider-side payment before a durable local transaction record is guaranteed to exist.
If the network response is lost, the frontend may retry the request.
Introduce a unique payment-attempt record before initiating the external charge.
Suggested flow:
Create local payment attempt
↓
Generate/retrieve idempotency key
↓
Call payment provider
↓
Persist external payment ID
↓
Update local payment state
↓
Return response
Retries for the same logical payment should reuse the same provider idempotency key.
Test:
Only one charge should result.
Severity: Medium Category: Payments / Data Integrity
Application-generated refunds update the reservation balance immediately.
Refunds initiated directly through the payment provider dashboard rely on a later webhook.
For a period of time, the application may display a different balance from the payment provider.
If webhook delivery permanently fails, the discrepancy may remain indefinitely.
Treat provider events as financial state updates rather than optional notifications.
Recommended controls:
Flag any reservation where:
local paid amount != provider settled amount
for manual review.
Severity: Medium Category: Money Logic
The backend verifies that a payment amount is positive, but does not consistently enforce that the amount is less than or equal to the remaining reservation balance.
Outstanding balance: $600.00
Requested payment: $700.00
The payment may be processed successfully even though the reservation only requires $600.
This creates:
Perform the validation on the server immediately before creating the payment.
The validation should use the current transactional database state rather than a balance supplied by the frontend.
Where concurrency is possible, lock or atomically update the relevant reservation/payment state.
Severity: Medium Category: Money Math
The application uses both decimal dollar amounts and integer cents in different parts of the system.
Examples:
1299.50
129950
Converting repeatedly between these formats increases the likelihood of:
Choose one canonical representation.
Recommended:
amountCents: number
Use integers for all application arithmetic.
Convert to formatted dollar values only for display.
Severity: Low Category: API Security
Unhandled exceptions are returned to the frontend with the original error message.
Example:
{
"error": "relation payment_records does not exist"
}
Detailed infrastructure errors may disclose:
Return generic client errors.
Example:
{
"error": "Unable to process request"
}
Log detailed diagnostic information only in protected server-side logs.
Severity: Low Category: Logging / Privacy
Some function logs include:
guest email
reservation identifier
trip name
payment amount
Although these values may not be highly sensitive individually, retaining them unnecessarily increases privacy exposure and operational risk.
Use structured logs with minimum necessary context.
Preferred:
request_id
reservation_internal_id
operation
result
duration
Avoid logging personal data unless it is required for a specific operational purpose.
The payment architecture correctly separates public browser configuration from private payment credentials.
Private provider credentials remain server-side.
This control should be preserved when environments are changed or deployment configuration is updated.
Row Level Security is enabled on the primary customer-facing database tables.
This provides a good security foundation.
However, having RLS enabled does not by itself guarantee correct authorization. Each policy must still be tested against every relevant role and access path.
Following remediation, I would verify:
Current Status: Remediation Required
The architecture is viable for production use, but the High-severity authorization and payment findings should be resolved before accepting real customer payments or storing production guest information.
A final re-check should focus specifically on validating the repaired controls rather than repeating the full audit.