Application Security Review

System: Travel Reservation & Payment Platform Review Scope: Authorization, Database Security, Serverless APIs, Payments, Money Handling, Secrets Reviewer: Julius Pratt Document Type: Illustrative Sample Report


Executive Summary

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:

Risk Summary

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.


Finding SEC-01

Server Endpoint Trusts Client-Supplied User Role

Severity: High Category: Authorization

Observation

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.

Risk

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.

Recommended Remediation

Determine authorization using trusted server-side identity.

The endpoint should:

  1. validate the session token
  2. retrieve the authenticated user's role from the database
  3. confirm access to the requested reservation
  4. perform the action only after those checks succeed

Do not trust:

when supplied directly by the client.

Re-Test

Attempt the request while authenticated as each role and manually alter every authorization-related property.


Finding SEC-02

Overly Broad Row Level Security Policy

Severity: High Category: Supabase / PostgreSQL

Observation

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.

Risk

A staff member may be able to enumerate guests for trips unrelated to their assigned work.

This may expose:

Recommended Remediation

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.

Re-Test

Create:

Test all cross-organization and cross-trip combinations.


Finding SEC-03

Security Definer Function Has Mutable Search Path

Severity: High Category: PostgreSQL

Observation

A privileged PostgreSQL function executes as SECURITY DEFINER without an explicitly fixed search_path.

Risk

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.

Recommended Remediation

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:

If elevated execution is unnecessary, convert the function to SECURITY INVOKER.


Finding PAY-01

Payment Retry Can Create Duplicate Charges

Severity: High Category: Payments

Observation

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.

Example Failure Scenario

  1. Customer submits $1,500 payment.
  2. Payment provider successfully charges card.
  3. Serverless function times out before responding.
  4. UI reports failure.
  5. Customer retries.
  6. A second charge is created.

Recommended Remediation

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.

Re-Test

Test:

Only one charge should result.


Finding PAY-02

Refund Processing Can Produce Temporary Balance Drift

Severity: Medium Category: Payments / Data Integrity

Observation

Application-generated refunds update the reservation balance immediately.

Refunds initiated directly through the payment provider dashboard rely on a later webhook.

Risk

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.

Recommended Remediation

Treat provider events as financial state updates rather than optional notifications.

Recommended controls:

Suggested Monitoring

Flag any reservation where:

local paid amount != provider settled amount

for manual review.


Finding DATA-01

Payment Allocation Can Exceed Outstanding Reservation Balance

Severity: Medium Category: Money Logic

Observation

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.

Example

Outstanding balance: $600.00
Requested payment:   $700.00

The payment may be processed successfully even though the reservation only requires $600.

Risk

This creates:

Recommended Remediation

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.


Finding DATA-02

Currency Calculations Use Mixed Representations

Severity: Medium Category: Money Math

Observation

The application uses both decimal dollar amounts and integer cents in different parts of the system.

Examples:

1299.50
129950

Risk

Converting repeatedly between these formats increases the likelihood of:

Recommended Remediation

Choose one canonical representation.

Recommended:

amountCents: number

Use integers for all application arithmetic.

Convert to formatted dollar values only for display.


Finding API-01

Serverless Function Exposes Internal Error Details

Severity: Low Category: API Security

Observation

Unhandled exceptions are returned to the frontend with the original error message.

Example:

{
  "error": "relation payment_records does not exist"
}

Risk

Detailed infrastructure errors may disclose:

Recommended Remediation

Return generic client errors.

Example:

{
  "error": "Unable to process request"
}

Log detailed diagnostic information only in protected server-side logs.


Finding OPS-01

Application Logs Contain Guest Identifiers

Severity: Low Category: Logging / Privacy

Observation

Some function logs include:

guest email
reservation identifier
trip name
payment amount

Risk

Although these values may not be highly sensitive individually, retaining them unnecessarily increases privacy exposure and operational risk.

Recommended Remediation

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.


Informational Finding INF-01

Strong Separation of Browser and Server Payment Credentials

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.


Informational Finding INF-02

RLS Enabled on Customer-Facing Tables

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.


Recommended Remediation Priority

Immediate

Before Launch

Hardening


Re-Test Checklist

Following remediation, I would verify:


Final Review Status

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.