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

Unsafe String Functions -- Potential Buffer Overflows #98

Open
henrygab opened this issue Sep 21, 2024 · 0 comments
Open

Unsafe String Functions -- Potential Buffer Overflows #98

henrygab opened this issue Sep 21, 2024 · 0 comments

Comments

@henrygab
Copy link
Contributor

henrygab commented Sep 21, 2024

The code uses sprintf() function, which has no integrated bounds checks. This has been considered a poor practice for both security and stability for many years.

On a hunch, I tracked the maximum bytes that would be written to a fixed buffer. The largest output would be >1400 characters, while the buffer is only 1024 bytes. All updates were using sprintf(), starting at an offset based on how much buffer was already used. None of these calls had any overflow prevention logic.

Therefore, it is STRONGLY recommended to:

  1. immediately deprecate the unsafe string functions, to generate compilation warnings when they are used.
  2. multiple small commits, each moving a few unsafe string function calls to the corresponding safe version.
  3. upon reaching zero usage of unsafe string functions, change the deprecation into compilation failures to prevent their accidental re-introduction.

Potential list of functions to deprecate, and potential replacements, can be found in the "Secure Development Lifecycle excerpt".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant