Closed Bug 1258669 Opened 9 years ago Closed 9 years ago

add checks for OPT builds in unix_rand.c

Categories

(NSS :: Libraries, defect)

defect
Not set
normal

Tracking

(firefox48 affected)

RESOLVED FIXED
Tracking Status
firefox48 --- affected

People

(Reporter: franziskus, Assigned: franziskus)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: [CID 1247620, CID 1247621][sg:low])

Attachments

(1 file)

unix_rand.c relies on PORT_Assert to check for successful file access. That won't work in optimised builds such that |read| is called on those file pointers even if the file wasn't be opened successfully.
Franziskus, can you comment on the potential security impact of this? Is it exploitable?
Flags: needinfo?(franziskuskiefer)
I think this particular issue is relatively low risk as NSS will read something, but not actually use it. > PORT_Assert(fd != -1); > while (limit > fileBytes) { > bytes = PR_MIN(sizeof buffer, limit - fileBytes); > bytes = read(fd, buffer, bytes); // read with fd == -1 > if (bytes <= 0) // bytes == -1 here so we bail > break;
Flags: needinfo?(franziskuskiefer)
Whiteboard: CID 1247620, CID 1247621 → [CID 1247620, CID 1247621][sg:low]
Attachment #8733841 - Flags: review?(ttaubert)
Assignee: nobody → franziskuskiefer
Comment on attachment 8733841 [details] [diff] [review] urand_read_file.patch Review of attachment 8733841 [details] [diff] [review]: ----------------------------------------------------------------- This seems fine as a fix but I'm worried about the behavior when opening /dev/urandom fails. The RNG_SystemRNG() callers seem to properly fail when we read zero bytes, all RNG_FileUpdate() call sites however do not seem to check if the call succeeded. I think that while we're here we probably should fix that or at least determine that it's fine to not check.
Attachment #8733841 - Flags: review?(ttaubert) → feedback+
889116(In reply to Tim Taubert [:ttaubert] from comment #4) > Comment on attachment 8733841 [details] [diff] [review] > urand_read_file.patch > > Review of attachment 8733841 [details] [diff] [review]: > ----------------------------------------------------------------- > > This seems fine as a fix but I'm worried about the behavior when opening > /dev/urandom fails. The RNG_SystemRNG() callers seem to properly fail when > we read zero bytes, all RNG_FileUpdate() call sites however do not seem to > check if the call succeeded. I think that while we're here we probably > should fix that or at least determine that it's fine to not check. I agree, but we have to be careful to do this only on systems where a certain that we have /dev/urandom. But lets do this in Bug 889116 that was filed for this.
See Also: → 889116
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Group: crypto-core-security → core-security-release
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: