Based on my testing so far, it appears that this plugin will expose servers to cross-user data leakage by default.
Starting with an empty Redis database:
1 Send a request as User A
PUT http://localhost:3000/profile/:id
authorization: XXXXXXXXXXXX
content-type: application/json
Idempotency-Key: dabfd044-7415-488f-b163-432ccb6eb11f
{
"firstname": "Jimmy"
}
2 Note successful response and cache key populated in Redis
{"status":"COMPLETE","fingerPrint":"9b76a708ee1e155d0806162ba4ec5778558e13a5567fe31d33e11a575814a000","response":{"additional":{"statusCode":200},"body":{"message":"Profile updated"}}}
3 Send same request as User B
PUT http://localhost:3000/profile/:id
authorization: YYYYYYYYYYYYY
content-type: application/json
Idempotency-Key: dabfd044-7415-488f-b163-432ccb6eb11f
{
"firstname": "Jimmy"
}
4 Note response from cache
This will almost certainly be exposing servers to fairly significant risks in production. I suspect that #4 would help solve the problem.
Looking at other libraries like https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/idempotency/#choosing-a-payload-subset-for-idempotency, we could offer a the ability to specify a path using something like JMES paths. Simply putting the authorisation token in the fingerprint would solve the problem in this case (though may not support idempotent requests if tokens are refreshed).
It feels like extreme care needs to be taken with this library in production and that it's not suited for any multi-tenant applications.
Based on my testing so far, it appears that this plugin will expose servers to cross-user data leakage by default.
Starting with an empty Redis database:
1 Send a request as User A
2 Note successful response and cache key populated in Redis
3 Send same request as User B
4 Note response from cache
This will almost certainly be exposing servers to fairly significant risks in production. I suspect that #4 would help solve the problem.
Looking at other libraries like https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/idempotency/#choosing-a-payload-subset-for-idempotency, we could offer a the ability to specify a path using something like JMES paths. Simply putting the authorisation token in the fingerprint would solve the problem in this case (though may not support idempotent requests if tokens are refreshed).
It feels like extreme care needs to be taken with this library in production and that it's not suited for any multi-tenant applications.