Skip to content

Commit a6235fa

Browse files
CriGoTziluvatar
authored andcommitted
Adds not to README on decoded payload validation (#646)
Adds a note to the README that suggest that decoded payload should not be trusted and should be treated as user inputs.
1 parent 5ed1f06 commit a6235fa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: README.md

+5
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ jwt.sign({
125125

126126
(Synchronous) If a callback is not supplied, function acts synchronously. Returns the payload decoded if the signature is valid and optional expiration, audience, or issuer are valid. If not, it will throw the error.
127127

128+
> __Warning:__ When the token comes from an untrusted source (e.g. user input or external requests), the returned decoded payload should be treated like any other user input; please make sure to sanitize and only work with properties that are expected
129+
128130
`token` is the JsonWebToken string
129131

130132
`secretOrPublicKey` is a string or buffer containing either the secret for HMAC algorithms, or the PEM
@@ -234,6 +236,9 @@ jwt.verify(token, getKey, options, function(err, decoded) {
234236

235237
> __Warning:__ This will __not__ verify whether the signature is valid. You should __not__ use this for untrusted messages. You most likely want to use `jwt.verify` instead.
236238
239+
> __Warning:__ When the token comes from an untrusted source (e.g. user input or external request), the returned decoded payload should be treated like any other user input; please make sure to sanitize and only work with properties that are expected
240+
241+
237242
`token` is the JsonWebToken string
238243

239244
`options`:

0 commit comments

Comments
 (0)