Skip to content
Payments · Secret guide

Leaked Square OAuth Token: what to do in the first hour

High severityDetected onlyLast verified · 4 min read

Square OAuth credentials come in two kinds, and both are sensitive. An OAuth token or personal access token lets the holder call the Square API as the seller it was issued for, within the scopes granted. An OAuth application secret is the credential of the application itself: with it, someone can refresh seller tokens, revoke them, or impersonate your application toward Square. Depending on scopes, the reach includes payments, orders, customers, catalog and inventory. Revoke the token and rotate the secret first, then audit what they could do.

Check your GitHub account for leaked secrets — free

Provider
Square
Severity
High
Impact
Payments and customer data
Checked live by LeakWatch
No

What a Square OAuth token looks like

Square credentials start with a short, recognizable prefix of the form sq0 plus a letter family and two letters, then a dash and a body of letters, digits, dashes and underscores:

sq0i…-XXXX   token in the sq0i family (masked, 22 to 43 characters after the dash)
sq0c…-XXXX   application secret in the sq0c family (masked, 40 to 50 characters after the dash)

The first family begins with sq0i, followed by two lowercase letters. The second begins with sq0c, followed by two letters, and is the OAuth application secret shown in the Developer Console. It is longer than the first. Square’s older production access token starts with sq0atp- and is covered in the Square access token guide. Square’s newer tokens begin with EAAA, and those, including sandbox ones, are not covered by these two rules. The variable names you will usually see are SQUARE_ACCESS_TOKEN, SQUARE_APPLICATION_SECRET or SQUARE_CLIENT_SECRET. The application secret is not the same as the application ID, which is public and appears in authorization links.

How Square OAuth tokens get leaked

  • OAuth server code. A small web app that handles the seller authorization flow, committed with its application secret in the source.
  • Environment files. SQUARE_APPLICATION_SECRET or a token in a .env file, a compose file or a deployment configuration.
  • Sample projects. A tutorial or SDK sample copied and adapted, with real credentials replacing the placeholders before pushing.
  • Front-end code. A checkout page that calls the API directly with a token instead of making the call from a server.
  • Support threads and screenshots. The credentials page of the Developer Console captured with a secret visible, or pasted into an issue when asking for help.

What to do in the first hour

  1. Open the Developer Console (see the link below), pick the application, and find its credentials and OAuth pages. Match the exposed value by its first and last characters.
  2. Rotate the application secret if it leaked. Generate a new one on the OAuth page and update your server. Until you do, the old secret remains usable.
  3. Revoke the token. Use Square’s revoke endpoint for OAuth tokens. It can end one token or every token of a seller for your application, so decide which fits the situation, then ask the affected sellers to authorize again if needed.
  4. Deploy the new credentials from a secret manager and test one read call.
  5. Audit payments and refunds. Review payments, refunds, gift cards and invoices created since the exposure that you do not recognize.
  6. Audit orders, catalog and customers. Look for records created, changed or exported without your knowledge, and check the webhook subscriptions for endpoints that are not yours.
  7. Assess customer data. If customer records could have been read, you may have notification duties. Talk to Square support and a qualified adviser, then clean the code. See I accidentally pushed an API key to GitHub.

Not sure what else leaked from the same repository? Run a free scan.

Not sure what else leaked? Run a free scan.

Revoke it at Square

Square credentials are managed in the Square Developer Console, after you sign in with the account that owns the application. Open the application and use its credentials and OAuth sections to replace the exposed secret. Tokens issued to other sellers are revoked with the OAuth revoke call described in Square’s OAuth API documentation: it is authenticated with the application secret, takes your application ID, and accepts either an access token or a seller ID. A person has not confirmed the exact menu wording for this guide, and the console can change, so if what you see differs, look for the application’s OAuth page.

How LeakWatch detects it

Two rules cover these formats.

The rule called Square OAuth Token matches the prefix sq0i followed by two lowercase letters, a dash, and then 22 to 43 letters, digits, dashes or underscores. It needs no variable name nearby.

The rule called Square OAuth Token (2) matches sq0c followed by two lowercase letters, a dash and 40 to 50 letters, digits, dashes or underscores.

Both are case sensitive on the prefix: a prefix in capitals, or a body that is too short, is not reported. Both have severity high. These types are not checked live: LeakWatch does not send any request to Square with the value it found.

LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.

FAQ

Is the application ID a secret?

No. The application ID is public and appears in authorization links. The application secret is the sensitive value, and the one to rotate if it leaked.

Does rotating the application secret invalidate seller tokens?

Do not assume so. Revoke tokens explicitly through the OAuth revoke call, and check Square’s documentation for the current behavior.

Can someone take money from my sellers with this?

That depends on the scopes. A token with payment scopes can create or refund payments for that seller, so revoke first and audit payments afterwards.

Get alerted next time a secret leaks — create a free account

LeakWatch is not affiliated with Square.