Skip to main content

Insight | Apr 15, 2025

rope

Security First API Integrations: Lean on Your BFF

By Brent Schultz

Your frontend isn’t a security vault. Don’t treat it like one. 

It’s easy to forget that everything sent to the browser is visible to anyone who knows how to open DevTools. And in the rush to build responsive, client-heavy apps, many teams unintentionally expose sensitive data at its most vulnerable point — the user’s device.

f When you integrate APIs directly into the client, especially those that handle Personally Identifiable Information (PII) or financial data, you’re taking a gamble. Not just with user trust, but with regulatory compliance, your reputation, and potentially millions in liability.

What does “exposing” look like in the wild?

Client-side API exposures can take many forms:

  • A React app that loads a customer profile (name, email, address) before verifying the user’s identity.
     
  • A Vue app that fetches billing history using an access token stored in localStorage.
     
  • A public API endpoint returning full payment method details, protected only by a token that’s visible in browser requests.
     
  • JavaScript code that loads PII from a third-party API with credentials hardcoded into the frontend bundle.

Each of these patterns might work fine during development or internal testing. But in production, they expose a critical truth: the frontend cannot be trusted to protect sensitive data. 

Real-world risk: When PII and payment data leak

Several high-profile incidents highlight just how costly this can be. Consider:

  • A major fintech startup that exposed full bank account numbers in the browser via an unprotected API call. Anyone with a browser and the right user ID could pull the data.
     
  • An ecommerce company that stored payment processor tokens in localStorage, making them accessible to any malicious JavaScript injected via XSS. This is a classic vector for financial fraud.
     
  • A healthcare platform that lets users guess another user's ID and pull their medical profile, all because the API trusts the client’s request.

These aren’t bugs in the traditional sense. They’re architectural oversights — trusting the frontend with responsibilities it simply shouldn't have. 

Why this matters more than ever

With privacy laws like GDPR, CCPA, and PCI DSS enforcement getting tighter, leaking PII or payment information isn’t just a bad look. It’s a legal risk. Organizations found mishandling personal data can face: 

  • Heavy fines and legal action 

  • Mandatory breach notifications

  • Public trust erosion 

  • Long-term brand damage

4 ways to protect sensitive data in client-side apps

Here are four concrete steps you can take to avoid risky exposure:

1. Use a Backend-For-Frontend (BFF) model

Keep all sensitive API calls and tokens server-side. The frontend makes safe, minimal requests to your own backend, which securely talks to upstream services. A backend in this sense can range from things like serverless or edge functions to full blown middleware applications hosted on traditional servers. 

2. Never store long-lived or privileged tokens in the browser

Use short-lived access tokens, refresh securely, and lean on HTTP-only cookies if needed.

3. Avoid loading sensitive data unless the user is verified and authorized

Just being "logged in" isn’t enough. Implement role-based access control and fetch only what’s needed.

4. Treat every client request as untrusted

Validate, verify, and sanitize. Always re-check permissions on the server, not the frontend.

“Your frontend is not the right place to handle sensitive data. It’s a place for rendering, not protecting. By moving critical logic and data handling server-side, you’re not just protecting your users — you're protecting your company from serious risk.”

Brent Schultz

VP of Engineering

Drop us a line

Have a project in mind?

Contacting Third and Grove may cause awesomeness. Side effects include a website too good to ignore. Proceed at your own risk.

Reduced motion disabled