- 
                Notifications
    
You must be signed in to change notification settings  - Fork 33
 
[SDK-165] Fix user-controlled bypass of sensitive method (GSRR-709) #957
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear to me what exactly are we mitigating a possible security loophole. Need discussion
| _email = email; | ||
| _userId = userId; | ||
| _authToken = authToken; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not making sense.
_email is passed in completeUserLogin method above.
And that is set back to the same variable here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah so the input that is passed is setting the internal state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ayyanchira To further clarify these parameters come from storeAuthData's completion handler which captured them at storage time, ensuring we use exactly what was stored and preventing TOCTOU attacks where
keychain data could be tampered between storage and usage.
| 
           I have now added unit tests also and updated the comments to explain the fixes :)  | 
    
🔒 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