Repository navigation
[SDK-165] Fix user-controlled bypass of sensitive method (GSRR-709) - #957
Conversation
davidtruong
left a comment
There was a problem hiding this comment.
That new logic looks good to me.
Can we add some unit tests to ensure that the change works and the data can't be changed mid-flight like it was before?
Ayyanchira
left a comment
There was a problem hiding this comment.
Not clear to me what exactly are we mitigating a possible security loophole. Need discussion
|
I have now added unit tests also and updated the comments to explain the fixes :) |
| if (config.authHandler != null && authToken == null) { | ||
| IterableLogger.d(TAG, "Skipping sensitive operations - JWT auth enabled but no validated authToken present"); | ||
| if (_setUserSuccessCallbackHandler != null) { | ||
| _setUserSuccessCallbackHandler.onSuccess(new JSONObject()); |
There was a problem hiding this comment.
Don't we want to fail the callback since the setUser didn't actually set the user internally?
There was a problem hiding this comment.
@davidtruong makes sense I have updated the code and the tests now.
davidtruong
left a comment
There was a problem hiding this comment.
This looks fine. We'll want to update the documentation to provide troubleshooting information if the setUser function fails with the callback.
🔒 Security Fix: User-Controlled Bypass of Sensitive Methods (PSEC-636)
The Problem (In Simple Terms)
What was the vulnerability?
Our Android SDK had a security gap where a malicious user could potentially access another user's data. Here's how:
What could an attacker do?
If successful, they could:
registerForPush)syncInApp)syncMessages)Why was this possible?
The code had a classic TOCTOU (Time-Of-Check-Time-Of-Use) vulnerability:
The Solution
We implemented a completion handler pattern to eliminate the timing gap:
✅ Atomic Credential Flow with Completion Handler
What this prevents:
Attack Invalidation
Attack Scenario 1: Keychain Tampering Between Store and Use
storeAuthData(),completeUserLogin()uses tampered dataAttack Scenario 2: No AuthToken Validation
config.authHandler != null), authToken required for sensitive opsReferences