-
Notifications
You must be signed in to change notification settings - Fork 108
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
Crash in PRNGFixes.java:259 #1155
Comments
I saw this occur on an API 17 device. Edit: some more context - the change below moved the locking around getUrandomInputStream(): |
Hi, I', also getting this exception on an API 16 device.
The exception occurs after triggering Prior to that, I had called setSecretKey() via AuthenticationSettings. Can anyone assist? |
I've got an Android V4.2.2 API 17 device, and this could repro while acquiring token. |
I took a look. I believe that we closed the inputstream in engineNextBytes (for /dev/urandom) and subsequently attempted to read from it. getUrandomInputStream returns a reference to the input stream (it effectively treats the input stream as a singleton and keeps a static reference). Inside engineNextBytes we close that stream via the reference, but do not set it to null. Subsequent calls to getUrandomInputStream return a reference to a closed inputstream. I don't think there is any reason to close this stream given the frequency with which this is invoked. I'll submit a PR to address this shortly. |
Closed by #1244 |
java.lang.SecurityException: Failed to read from /dev/urandom at com.microsoft.aad.adal.PRNGFixes$LinuxPRNGSecureRandom.engineNextBytes(PRNGFixes.java:259) at java.security.SecureRandom.nextBytes(SecureRandom.java:272) at com.microsoft.aad.adal.StorageHelper.encrypt(StorageHelper.java:188) at com.microsoft.aad.adal.DefaultTokenCacheStore.encrypt(DefaultTokenCacheStore.java:125) at com.microsoft.aad.adal.DefaultTokenCacheStore.setItem(DefaultTokenCacheStore.java:190) at com.microsoft.aad.adal.TokenCacheAccessor.setItemToCacheForUser(TokenCacheAccessor.java:363) at com.microsoft.aad.adal.TokenCacheAccessor.updateTokenCache(TokenCacheAccessor.java:244) at com.microsoft.aad.adal.TokenCacheAccessor.updateCachedItemWithResult(TokenCacheAccessor.java:222) at com.microsoft.aad.adal.AcquireTokenSilentHandler.acquireTokenWithCachedItem(AcquireTokenSilentHandler.java:339) at com.microsoft.aad.adal.AcquireTokenSilentHandler.tryFRT(AcquireTokenSilentHandler.java:299) at com.microsoft.aad.adal.AcquireTokenSilentHandler.tryMRRT(AcquireTokenSilentHandler.java:247) at com.microsoft.aad.adal.AcquireTokenSilentHandler.tryRT(AcquireTokenSilentHandler.java:209) at com.microsoft.aad.adal.AcquireTokenSilentHandler.getAccessToken(AcquireTokenSilentHandler.java:107) at com.microsoft.aad.adal.AcquireTokenRequest.tryAcquireTokenSilentLocally(AcquireTokenRequest.java:438) at com.microsoft.aad.adal.AcquireTokenRequest.acquireTokenSilentFlow(AcquireTokenRequest.java:401) at com.microsoft.aad.adal.AcquireTokenRequest.tryAcquireTokenSilent(AcquireTokenRequest.java:354) at com.microsoft.aad.adal.AcquireTokenRequest.performAcquireTokenRequest(AcquireTokenRequest.java:333) at com.microsoft.aad.adal.AcquireTokenRequest.access$200(AcquireTokenRequest.java:47) at com.microsoft.aad.adal.AcquireTokenRequest$1.run(AcquireTokenRequest.java:111) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856)
The text was updated successfully, but these errors were encountered: