Skip to main content
CriticalSecretsOWASP A07:2021CWE-798

How to fix: PayPal OAuth client secret in source

PayPal client secrets are paired with a client ID and grant order/refund/payout operations on the merchant account.

Why it matters

An exposed PayPal client secret paired with the client ID lets an attacker create fraudulent orders, issue refunds to attacker-controlled accounts, trigger payouts, and access all transaction history on your merchant account.

PayPal client secrets are paired with a client ID and grant order/refund/payout operations on the merchant account.

How to fix it

  1. 1Rotate the secret at developer.paypal.com → My Apps & Credentials → Edit App → Regenerate Secret
  2. 2Keep the client secret server-side only; the client ID alone is safe in browsers
  3. 3Use the PayPal JS SDK (which handles auth client-side) for browser integrations

Code examples

Server-side PayPal token exchange (client secret stays server-only)

TypeScript
// Fetch an access token on the server: never expose client_secret to browsers
async function getPayPalAccessToken() {
  const credentials = Buffer.from(
    `${process.env.PAYPAL_CLIENT_ID}:${process.env.PAYPAL_CLIENT_SECRET}`
  ).toString('base64');

  const res = await fetch('https://api-m.paypal.com/v1/oauth2/token', {
    method: 'POST',
    headers: {
      Authorization: `Basic ${credentials}`,
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: 'grant_type=client_credentials',
  });

  const { access_token } = await res.json();
  return access_token;
}

References

Detected automatically by VulnRadar. The check id is secret-paypal-client-secret, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is PayPal OAuth client secret in source?
VulnRadar rates this critical severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id secret-paypal-client-secret, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does PayPal OAuth client secret in source map to?
It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for paypal oauth client secret in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: PayPal OAuth client secret in source | VulnRadar