Case study

JRB Premier Ride

October 28, 2026 PCI DSSStripeCSPTrusted TypesAPI securitySPF / DKIM / DMARCCAADNSSEC

jrbpremierride.com is the booking site for JRB Premier Ride, a Los Angeles black-car service. I built it and maintain it through deltoro.codes.

The project

Security

It takes bookings and money, so the attack surface is the browser, the API, the payment flow, and the domain. I hardened it end to end and rolled it out in stages so nothing broke in production.

A+

140 / 100 on Mozilla’s HTTP Observatory, 12 of 12 tests passed (baseline before this work: A+, 135). View the live report.

01Threat model

A booking app that takes payments has more to protect than a static site:

02Starting point

I ran a baseline scan before changing anything. The site was already at A+ (135): HTTPS, a CSP with no 'unsafe-inline' (a postbuild step moves the prerenderer’s inline scripts into external files), Helmet, CORS, Zod validation, rate limiting, signed Stripe webhooks, and DNSSEC. The gaps:

03Payments and PCI scope

Payment uses Stripe Checkout (hosted): the browser is redirected to checkout.stripe.com, so card data never touches the site, its scripts, or the API. That keeps the merchant at PCI DSS SAQ A, the lightest self-assessment.

Because Checkout is a full-page redirect, the CSP needs no Stripe origins at all. Adding js.stripe.com “just in case” would only widen the policy. If the site ever moves to Stripe Elements, it would need js.stripe.com in script-src and frame-src, and api.stripe.com in connect-src.

04Front end: deny-by-default CSP and Trusted Types

I self-hosted the Marcellus webfont via @fontsource (its Latin subset covers English and Spanish) and removed Google Fonts, so the site makes no requests to any origin except its own, the API, and Mapbox’s search API. I also removed the unused mapbox-gl package. The final policy, with the API’s origin replaced by a placeholder:

default-src 'none';
script-src 'self'; style-src 'self'; font-src 'self';
img-src 'self' data:;
connect-src 'self' <api-origin>
            https://api.mapbox.com;
manifest-src 'self'; form-action 'self'; base-uri 'none';
object-src 'none'; frame-src 'none'; worker-src 'none';
frame-ancestors 'none';
require-trusted-types-for 'script'; trusted-types default;
upgrade-insecure-requests

Trusted Types with React. This app can’t use trusted-types 'none', because it has one legitimate sink: the head manager writes each page’s JSON-LD structured data with innerHTML during client-side navigation. The solution is a single default policy, loaded as the first script, whose createHTML accepts a string only if it contains no <, since text without < can’t create elements, attributes, or event handlers. There is deliberately no createScript or createScriptURL, so string-to-script stays blocked outright. I verified in the browser that markup injection through HTML sinks throws, and that a script whose text is set from a string never executes.

05HTTP response headers

HeaderWhy
Content-Security-PolicyDeny-by-default; only the site itself, the API, and Mapbox search; Trusted Types enforced.
Strict-Transport-SecurityTwo years with includeSubDomains (raised from one year).
X-Frame-Options: DENYClickjacking protection for older browsers; frame-ancestors covers modern ones.
X-Content-Type-Optionsnosniff.
Referrer-Policystrict-origin-when-cross-origin.
Permissions-PolicyGeolocation only for the site itself (the “use my location” pickup button); camera, microphone, payment, USB, motion sensors, display capture and ad-topics disabled. payment=() is correct because Stripe Checkout runs on Stripe’s own page.
Cross-Origin-Opener-Policysame-origin.
Cross-Origin-Resource-Policysame-origin (tightened from same-site).

06The API

07Domain: email and certificates

I identified the providers before writing any records. DNS and the registrar are Squarespace Domains; the domain receives no mail (no MX); and the only sender is Resend (on Amazon SES) for booking notifications.

@                  TXT  "v=spf1 -all"
send               TXT  "v=spf1 include:amazonses.com ~all"
resend._domainkey  TXT  (Resend DKIM key, already present)
_dmarc             TXT  "v=DMARC1; p=quarantine;"
@                  CAA  0 issue "pki.goog"
@                  CAA  0 issue "letsencrypt.org"

08Rollout and verification

The rule throughout: never tighten a header before the code that needs it is live.

09Follow-ups

For a small business that takes payments online, this is the standard I aim for: card data never touches the site, and every layer around checkout is locked down and verified in production.

← Back to projects
Caso de estudio

JRB Premier Ride

28 de octubre de 2026 PCI DSSStripeCSPTrusted TypesSeguridad de APISPF / DKIM / DMARCCAADNSSEC

jrbpremierride.com es el sitio de reservas de JRB Premier Ride, un servicio de autos ejecutivos en Los Ángeles. Lo desarrollé y lo mantengo a través de deltoro.codes.

El proyecto

Seguridad

Este sitio recibe reservas y dinero, así que la superficie de ataque abarca el navegador, la API, el flujo de pago y el dominio. Lo protegí de principio a fin y lo implementé por etapas para que nada fallara en producción.

A+

140 / 100 en el HTTP Observatory de Mozilla, 12 de 12 pruebas superadas (punto de partida antes de este trabajo: A+, 135). Ver el informe en vivo.

01Modelo de amenazas

Una aplicación de reservas que cobra tiene más que proteger que un sitio estático:

02Punto de partida

Antes de cambiar nada, hice un análisis de referencia. El sitio ya tenía A+ (135): HTTPS, una CSP sin 'unsafe-inline' (un paso posterior a la compilación traslada los scripts en línea del prerrenderizador a archivos externos), Helmet, CORS, validación con Zod, límites de solicitudes, webhooks de Stripe firmados y DNSSEC. Las deficiencias:

03Pagos y alcance de PCI

El pago usa Stripe Checkout (alojado por Stripe): el navegador se redirige a checkout.stripe.com, así que los datos de la tarjeta nunca pasan por el sitio, sus scripts ni la API. Eso mantiene al comercio en PCI DSS SAQ A, la autoevaluación más sencilla.

Como Checkout es una redirección de página completa, la CSP no necesita ningún origen de Stripe. Agregar js.stripe.com «por si acaso» solo ampliaría la política. Si algún día el sitio pasa a Stripe Elements, necesitará js.stripe.com en script-src y frame-src, y api.stripe.com en connect-src.

04Front end: CSP que deniega por defecto y Trusted Types

Alojé la tipografía Marcellus en el propio sitio mediante @fontsource (su subconjunto latino cubre el inglés y el español) y eliminé Google Fonts, de modo que el sitio no hace solicitudes a ningún origen salvo el propio, la API y la API de búsqueda de Mapbox. También eliminé el paquete mapbox-gl, que no se usaba. La política final, con el origen de la API sustituido por un marcador de posición:

default-src 'none';
script-src 'self'; style-src 'self'; font-src 'self';
img-src 'self' data:;
connect-src 'self' <api-origin>
            https://api.mapbox.com;
manifest-src 'self'; form-action 'self'; base-uri 'none';
object-src 'none'; frame-src 'none'; worker-src 'none';
frame-ancestors 'none';
require-trusted-types-for 'script'; trusted-types default;
upgrade-insecure-requests

Trusted Types con React. Esta aplicación no puede usar trusted-types 'none', porque tiene un punto de inserción legítimo: el gestor del <head> escribe los datos estructurados JSON-LD de cada página con innerHTML durante la navegación del lado del cliente. La solución es una única política default, cargada como el primer script, cuyo createHTML solo acepta una cadena si no contiene <: un texto sin < no puede crear elementos, atributos ni manejadores de eventos. A propósito no tiene createScript ni createScriptURL, así que convertir una cadena en script sigue bloqueado por completo. Comprobé en el navegador que inyectar marcado a través de los puntos de inserción de HTML genera un error, y que un script cuyo texto se asigna desde una cadena nunca se ejecuta.

05Encabezados de respuesta HTTP

EncabezadoPropósito
Content-Security-PolicyDeniega por defecto; solo el propio sitio, la API y la búsqueda de Mapbox; Trusted Types aplicado.
Strict-Transport-SecurityDos años con includeSubDomains (antes, un año).
X-Frame-Options: DENYProtección contra clickjacking para navegadores antiguos; frame-ancestors cubre los modernos.
X-Content-Type-Optionsnosniff.
Referrer-Policystrict-origin-when-cross-origin.
Permissions-PolicyUbicación permitida solo para el propio sitio (el botón «usar mi ubicación» para el punto de recogida); cámara, micrófono, pagos, USB, sensores de movimiento, captura de pantalla y temas publicitarios desactivados. payment=() es correcto porque Stripe Checkout se ejecuta en la página de Stripe.
Cross-Origin-Opener-Policysame-origin.
Cross-Origin-Resource-Policysame-origin (antes, same-site).

06La API

07Dominio: correo y certificados

Identifiqué a los proveedores antes de escribir cualquier registro. El DNS y el registrador son Squarespace Domains; el dominio no recibe correo (sin MX); y el único remitente es Resend (sobre Amazon SES), para las notificaciones de reservas.

@                  TXT  "v=spf1 -all"
send               TXT  "v=spf1 include:amazonses.com ~all"
resend._domainkey  TXT  (Resend DKIM key, already present)
_dmarc             TXT  "v=DMARC1; p=quarantine;"
@                  CAA  0 issue "pki.goog"
@                  CAA  0 issue "letsencrypt.org"

08Implementación y verificación

La regla en todo momento: nunca endurecer un encabezado antes de que esté en producción el código que lo necesita.

09Seguimiento

Para una pequeña empresa que cobra en línea, este es el estándar que busco: los datos de la tarjeta nunca pasan por el sitio, y cada capa alrededor del pago está protegida y verificada en producción.

← Volver a proyectos