security: Fix top 5 low severity vulnerabilities from Snyk scan #18
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.
Security: Fix Top 5 Low Severity Vulnerabilities from Snyk Scan
Make sure to read the contributing guidelines before submitting a PR
Summary
This PR addresses 5 low-severity security vulnerabilities identified by Snyk static analysis, focusing on resource management, cryptographic best practices, and credential handling in test code.
Link to Devin run: https://app.devin.ai/sessions/a123af34a4d04c91a87e8851205a8a8f
Requested by: Jake Cosme ([email protected]) / @jakexcosme
Changes
1. File Handle Management (
common/log.cpp
)nullptr
afterfclose()
to prevent use-after-freefopen()
fails2. Cryptographic Hash Deprecation (
gguf-py/gguf/scripts/gguf_hash.py
)3. Hardcoded Credentials in Tests (
tools/server/tests/unit/test_chat_completion.py
)api_key="dummy"
with environment variableTEST_API_KEY = os.getenv("LLAMA_SERVER_TEST_API_KEY", "dummy")
Human Review Checklist
gguf_hash.py
output format change doesn't break downstream toolingcommon/log.cpp
changes compile successfully in full project contextTesting
Notes
Files with null termination and file handle issues in
linenoise.cpp
were reviewed and found to already have proper handling (RAII destructor for files, explicit null termination afterstrncpy
), so no changes were made to that file.