Skip to content
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

Incorrect conversion specifiers #2573

Closed
steven-bellock opened this issue Feb 15, 2024 · 0 comments · Fixed by #2574
Closed

Incorrect conversion specifiers #2573

steven-bellock opened this issue Feb 15, 2024 · 0 comments · Fixed by #2574
Assignees
Labels
bug Something isn't working security An issue that impacts security

Comments

@steven-bellock
Copy link
Contributor

There are many instances of

LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
"libspdm_challenge - libspdm_encapsulated_request - %p\n", status));
where status is a uint32_t. If libspdm_debug_print passes this to the C printf function then the behavior is undefined.

If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.

Most compilers can detect this issue. However the libspdm_debug_print function masks this.

There are a few issues and tasks that arise from this.

  1. The conversion specifiers need to be changed. (This issue)
  2. The documentation for libspdm_debug_print needs to specify that format and ... follow C printf conventions.
  3. For CI/CD the LIBSPDM_DEBUG macro needs to be overridden such that it can be replaced with printf. Then the compiler can detect issues like this during compilation.

Even though this invokes undefined behavior I do not consider it much of a vulnerability, since

  • This issue only arises in a debug build.
  • For most (all?) compilers the behavior is benign. Most just print the value of the integer.
@steven-bellock steven-bellock added bug Something isn't working security An issue that impacts security labels Feb 15, 2024
@steven-bellock steven-bellock self-assigned this Feb 15, 2024
steven-bellock added a commit to steven-bellock/libspdm that referenced this issue Feb 15, 2024
Fix DMTF#2573.

Signed-off-by: Steven Bellock <[email protected]>
steven-bellock added a commit to steven-bellock/libspdm that referenced this issue Feb 15, 2024
Fix DMTF#2573.

Signed-off-by: Steven Bellock <[email protected]>
jyao1 pushed a commit that referenced this issue Feb 18, 2024
Fix #2573.

Signed-off-by: Steven Bellock <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security An issue that impacts security
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant