GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DxeRngLib: GetRandomNumber spurious success by idigdoug · Pull Request #6486 · tianocore/edk2

Conversation

@idigdoug

@idigdoug idigdoug commented Dec 1, 2024

Copy link
Copy Markdown
Contributor

Description

The GetRandomNumber functions in DxeRngLib can return success without actually generating a random number. This occurs because there is a code path through GenerateRandomNumberViaNist800Algorithm that does not update the output buffer and does not initialize the Status variable.

  • Assume mFirstAlgo == MAX_UINTN (no secure algorithms available)
  • Assume none of the secure algorithms have Available set.
  • Assume PcdEnforceSecureRngAlgorithms is TRUE.

In this condition, the Status variable is never initialized, Buffer data is never touched. It is fairly likely that Status is 0, so we can return EFI_SUCCESS without writing anything to Buffer.

Fix is to set Status = error_code in this code path. EFI_SECURITY_VIOLATION seems appropriate.

  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

  • Observed EFI_SUCCESS returned from GetRandomNumber16 even though output value remained 0.
  • Applied fix.
  • Observed EFI_SECURITY_VIOLATION returned from GetRandomNumber16 when expected.
  • Set PcdEnforceSecureRngAlgorithms to false, observed successful RNG generation.

Integration Instructions

N/A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the impact:security This change has a direct security impact such as changing a crypto algorithm. label Dec 1, 2024
@tianocore-assign-reviewers
tianocore-assign-reviewers Bot requested review from LiuZhiguang001, lgao4 and mdkinney December 1, 2024 01:26
pierregondois
pierregondois approved these changes Dec 2, 2024
View reviewed changes
mdkinney
mdkinney approved these changes Dec 2, 2024
View reviewed changes
lgao4
lgao4 approved these changes Dec 6, 2024
View reviewed changes
@lgao4 lgao4 added the push Auto push patch series in PR if all checks pass label Dec 6, 2024
idigdoug and others added 2 commits December 6, 2024 09:14
@idigdoug @lgao4
DxeRngLib: GetRandomNumber spurious success
8a15486
The GetRandomNumber functions in DxeRngLib can return success without
actually generating a random number. This occurs because there are code
paths through `GenerateRandomNumberViaNist800Algorithm` that do not
initialize the `Status` variable.

- Assume mFirstAlgo == MAX_UINTN (no secure algorithms available)
- Assume none of the secure algorithms have `Available` set.
- Assume PcdEnforceSecureRngAlgorithms is TRUE.

In this condition, the `Status` variable is never initialized, `Buffer`
data is never touched. It is fairly likely that Status is 0, so we can
return EFI_SUCCESS without writing anything to Buffer.

Fix is to set `Status = error_code` in this code path.
`EFI_SECURITY_VIOLATION` seems appropriate.

Signed-off-by: Doug Cook <[email protected]>
@mergify
Merge branch 'master' into DxeRngStatus
b3f8fca
@mergify
mergify Bot merged commit fd9501f into tianocore:master Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lgao4 lgao4 lgao4 approved these changes
@mdkinney mdkinney mdkinney approved these changes
@LiuZhiguang001 LiuZhiguang001 Awaiting requested review from LiuZhiguang001
+1 more reviewer
@pierregondois pierregondois pierregondois approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

impact:security This change has a direct security impact such as changing a crypto algorithm. push Auto push patch series in PR if all checks pass

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@idigdoug @lgao4 @mdkinney @pierregondois
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.