-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provider.checkToken
will no longer treat empty refreshToken
strings as invalid tokens and fixed use of __proto__
as identityId
in IdentitiesManager
#604
Conversation
If this works, proceed to squash down, no need to keep unnecessary lintfix commits around, and merge in. Are you waiting for something here? |
99a35e4
to
d3ecf58
Compare
Provider.checkToken
will no longer treat empty refreshToken
strings as invalid tokensProvider.checkToken
will no longer treat empty refreshToken
strings as invalid tokens and added prototype polution errors in IdentitiesManager
https://chat.openai.com/share/caaac780-4de6-4b1a-ab6a-68cd4ed58cd8 This explains that explicitly set |
In #608 I've explained how you can support |
To summarise for safety reasons, if the key is coming from an untrusted source, or a randomised source where you don't know what it could be, there's 2 safe ways of doing this:
It is not safe to do |
Can you fix it that way, and add an inline comment describing the reason. |
d3ecf58
to
8142056
Compare
// This has to be done in case the key is `__proto__`.
// Otherwise, the object will not be correctly serialized.
// https://github.com/MatrixAI/Polykey/issues/608
Object.defineProperty(providerTokens, identityId, {
value: providerToken,
writable: true,
enumerable: true,
configurable: true,
}); |
Provider.checkToken
will no longer treat empty refreshToken
strings as invalid tokens and added prototype polution errors in IdentitiesManager
Provider.checkToken
will no longer treat empty refreshToken
strings as invalid tokens and fixed use of __proto__
as identityId
in IdentitiesManager
8142056
to
695084e
Compare
…strings as falsy chore: lintfix [ci-skip]
… avoid serialisation issues when the `identityId` is `__proto__` [ci-skip]
695084e
to
42a2280
Compare
Description
Provider
The
handleClaimIdentity
test intests/identities/IdentitiesManager.test.ts
was failing onhandleClaimIdentity
. This was because it was treating refreshTokens of empty strings as invalid tokens. This is no longer the case.It is also defined now that any expiry values in AccessToken set to 0, now have their related tokens treated as never-expiring. This was already the case before this PR, but inline comments have been added to document this.
Prototype Pollution
During testing, I noticed two other tests in
IdentitiesManager.test.ts
failing. This was because of fastcheck sometimes generating a string value of__proto__
for theidentityId
. TheidentityId
is used as the key for the object that comes out of RocksDB, there is a problem with prototype pollution. This is not only a security issue, but also thatJSON.stringify
does not serialize the__proto__
property of an object, so certain the provider keys for that identity will never work. This PR usesObject.defineProperty
to correctly set the__proto__
property on theproviderTokens
object.Issues Related
getToken
andputToken
whenidentityId
is__proto__
#608Tasks
refreshToken
TestProvider.refreshToken
identityId
is attemptedFinal checklist