A Val Town API token lets a script or tool act as your Val Town account through the Val Town API. Val Town runs small pieces of JavaScript or TypeScript on its servers, called vals, and some of them hold environment variables with secrets that the vals use. A token with the wrong scope can read or change the code of your vals, and the code can then run with access to whatever those variables open. Revoke the token first, then review the vals and their variables for changes.
Check your GitHub account for leaked secrets — free
- Provider
- Val Town
- Severity
- High
- Impact
- Source code and build access
- Checked live by LeakWatch
- No
What a Val Town API Token looks like
Val Town API tokens begin with vtwn_, followed by a run of letters, digits, underscores and hyphens of moderate length. The prefix is the signal to look for:
vtwn_…XXXX Val Town API token (masked)
Tokens are sent as bearer tokens in an Authorization header. They can be scoped by resource, so a token may be allowed to read vals but not to write them, and some scopes are off by default. The scopes are part of the risk: a token with write access to vals can change the code that runs on your account. A short value with the prefix, such as a truncated example in documentation, is not a working token, but any value that looks like a real token should be handled as one.
How Val Town API Tokens get leaked
- Scripts that deploy or update vals. A deployment script that holds the token so that it can publish code, pushed to a repository.
- Environment files. A
.envfile used by a local development setup, committed or copied into a template. - Shared code. A val that was copied or forked with a token in its code, then published or shared with someone else.
- Logs and terminals. A debug print of the request headers, or a terminal session recorded or shared while setting up a tool.
- Snippets and support threads. A token pasted into a forum post or a chat when an API call returned an authorization error.
What to do in the first hour
- Delete the token. Open the account settings for your Val Town account, find the API token in the list, and delete it. Deleting a token cuts off its access straight away, so update the tools that use it afterwards.
- Create a replacement with only the scopes the tool needs. Store it in a secret manager or the environment of the process that uses it, and never in a val’s own code.
- Review your vals. List the vals on the account and check their recent changes. Look for code you did not write, new vals, and edits to existing ones, especially any that send requests to outside servers.
- Check environment variables. Review the variables stored for each val. Rotate any secret that a val reads, because the token could have been used to read those values.
- Check the scheduled and HTTP vals. A val that runs on a schedule or responds to web requests can keep working after the token is gone, so look at what is running and disable what you do not recognize.
- Check the rest of the file. Revoke other credentials stored with the token, such as database passwords or cloud keys.
- Clean the repository. Remove the value from current files, add the file to
.gitignore, and rewrite history if the repository was public. See I accidentally pushed an API key to GitHub for the full order.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at Val Town
Val Town’s documentation says tokens are created and managed on the API Tokens page of the account settings, and that deleting a token on that page cuts its access right away. The same page is where you choose the scopes, and where you set expiry dates. Give the replacement the narrowest scope the tool needs, set an expiry so that it is rotated automatically, and avoid giving write access to vals unless the job requires it. We could not confirm every button label from the live page, so check the names in your own account. If the leaked token had broad scope, review the vals and their variables before assuming the damage is limited.
How LeakWatch detects it
The rule is called “Val Town API Token”. It looks for the prefix vtwn_ followed by 20 to 80 letters, digits, underscores or hyphens, with a word boundary before the prefix and a quote, space, semicolon or line end after the value. A value shorter than 20 characters after the prefix is not reported. The severity is high, with the identity and code impact class, because the token can change code that runs on your account. This type is not checked live: LeakWatch does not send the value to Val Town, so a finding means the value has the right shape, not that it still works.
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
Can a leaked Val Town token change running code?
Yes, if the token has write scope for vals. That is why the first step is to delete the token and then compare the code of every val with what you expect.
Are the environment variables safe if the token was read-only?
Not necessarily. A read-only token can still read variables and code, and those can contain secrets. Rotate any secret that a val depends on if you cannot confirm that the token was never used.
What is a safe way to set up a token for a tool?
Create one per tool, scope it to what the tool needs, set an expiry date, and store it in your secret store. Remove the token from the tool when the tool is retired.