What is a JWT and why you shouldn't store secrets inside it?
Published on 2026-10-20 by frfrand
What is a JWT: header, payload and signature, why signed does not mean encrypted, how to validate exp, iss and aud, and where to store it in the browser.

Short answer: a JWT (JSON Web Token) is a token format that transports claims between systems in three parts: header, payload, and signature. The signature allows detecting if someone modified it, but it does not hide anything: anyone can decode its content, so secrets are not stored inside.
Many applications use it to exchange information about sessions and permissions. The name comes from JSON Web Token.
The most important warning is this: a signed JWT is normally not encrypted. The fact that it looks like an illegible string does not mean it is a safe place to store passwords.
The three parts that usually appear
A signed compact JWT usually contains three segments separated by dots:
encabezado.contenido.firma
The header indicates information such as the algorithm. The content—or payload—carries claims known as claims. The signature allows checking integrity and authenticity under certain conditions, if validated correctly.
The segments use representations that can be decoded. That is why a user identifier or an expiration date can be read without knowing a secret password.
What is it for?
Imagine that a user authenticates in an application. The server can issue a token that another component validates to recognize certain claims during its validity period.
In some architectures this simplifies communication between services. In others, a traditional session maintained on the server is simpler and allows immediate revocation with fewer complications.
There is no obligation to use JWT just because you are developing a modern API.
What do exp, iss and aud mean?
exp is a common expiration claim, iss identifies the issuer and aud indicates the intended audience.
A secure implementation is not limited to checking the signature. It must also verify which issuer is trusted, for which audience the token was issued, if it has already expired and if the declared permissions are relevant for the operation.
A token valid for another API should not be able to be reused indiscriminately in yours.
Does JWT mean I don't need a database?
Not necessarily. Your application can still query permissions, account statuses or resources. A user can lose access to a project before the received token expires.
If all authorization depends on outdated claims, you could allow actions that have already been revoked. The expiration policy and revocation mechanism must be designed keeping this risk in mind.
Where is the token stored in the browser?
It is a decision with trade-offs. Storing it in JavaScript-accessible storage can increase the impact of certain XSS attacks. Cookies with appropriate attributes can reduce certain risks, but CSRF, domain scope, and duration must also be considered.
There is no single answer without knowing the architecture. Avoid repeating recipes such as "JWT always in localStorage" or "JWT always in cookies" without evaluating the threat model.
Common mistakes
Putting secrets in the payload. If the token is not encrypted, that data is recoverable.
Accepting unexpected algorithms or issuers. Validation must be strict and use a trusted configuration.
Using excessive expirations without revocation. If the token is leaked, it may allow access for longer than reasonable.
Confusing JWT with OAuth. One is a format; the other is an authorization framework. They can be used together, but they are not synonyms.
An example in ArduMaker
If an application hosted on a VPS managed from ArduMaker uses JWT tokens, the application server must validate them correctly and check permissions on each resource. Hosting does not automatically turn an insecure token into a trusted one.
The key used to sign tokens is not included in the repository either. If the app is deployed from GitHub, declare it as an environment variable in the deploy configuration: variables named as secrets are stored as references and not as values, and on the VPS they are written to a file outside the repository that only the application user can read.
To remember: the signature of a JWT helps verify its integrity, not to hide its content. Security depends on how it is issued, validated, stored, and revoked.
Frequently asked questions
Is a JWT encrypted? Normally not. A signed JWT (JWS) only guarantees integrity. There is an encrypted variant (JWE), but it is less common and not what an API usually uses.
How do I invalidate a JWT before it expires? You cannot "delete" an issued token. Short expirations are used, a revoked token list, or an account status check on each sensitive operation.
Related: What is OAuth 2.0.
Sources: RFC 7519, JSON Web Token · JWT best practices at OWASP.
