FIX: prevent native log format-string injection - #791
Open
Sumit Sarabhai (sumitmsft) wants to merge 2 commits into
Open
Sumit Sarabhai (sumitmsft) wants to merge 2 commits into
Sumit Sarabhai (sumitmsft) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Sumit Sarabhai (sumitmsft)
September 17, 2026 08:32
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
Prevents native printf-style log injection from server-controlled metadata and adds compile-time validation.
Changes:
- Converts dynamic log calls to literal formats.
- Fixes format mismatches.
- Adds compiler checks and regression tests.
File summaries
| File | Description |
|---|---|
tests/test_039_native_logging_format_security.py |
Adds logging format-security regression tests. |
mssql_python/pybind/logger_bridge.hpp |
Adds printf-format annotations. |
mssql_python/pybind/ddbc_bindings.cpp |
Secures and corrects native log calls. |
mssql_python/pybind/CMakeLists.txt |
Enables format diagnostics. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
mssql_python/pybind/ddbc_bindings.cppLines 2746-2755 2746 if (PyBytes_GET_SIZE(b.ptr()) != 16) {
2747 LOG("BindParameterArray: GUID bytes wrong "
2748 "length - param_index=%d, row=%zu, "
2749 "length=%lld",
! 2750 paramIndex, i,
! 2751 static_cast<long long>(PyBytes_GET_SIZE(b.ptr())));
2752 ThrowStdException("UUID binary data must be "
2753 "exactly 16 bytes long.");
2754 }
2755 std::memcpy(uuid_bytes.data(), PyBytes_AS_STRING(b.ptr()), 16);Lines 2774-2783 2774 std::memcpy(guidArray[i].Data4, uuid_bytes.data() + 8, 8);
2775 strLenOrIndArray[i] = sizeof(SQLGUID);
2776 }
2777 LOG("BindParameterArray: SQL_C_GUID bound - "
! 2778 "param_index=%d, count=%zu",
! 2779 paramIndex, paramSetSize);
2780 dataPtr = guidArray;
2781 bufferLength = sizeof(SQLGUID);
2782 break;
2783 }📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 61.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.row.py: 77.6%
mssql_python.pybind.ddbc_bindings.cpp: 77.7%
mssql_python.pybind.connection.connection_pool.cpp: 81.8%
mssql_python.logging.py: 86.2%
mssql_python.pooling.py: 90.1%
mssql_python.pybind.py_type_cache.hpp: 91.6%🔗 Quick Links
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Sumit Sarabhai (sumitmsft)
September 17, 2026 10:22
View session
Sumit Sarabhai (sumitmsft)
marked this pull request as ready for review
September 17, 2026 10:27
Copilot stopped reviewing on behalf of
Sumit Sarabhai (sumitmsft) due to an error
September 17, 2026 10:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Work Item / Issue Reference
Summary
Prevents server-controlled Arrow column metadata from being interpreted as a native printf-style format string.
Converts all dynamic native LOG calls to literal formats, fixes existing format/argument mismatches exposed by compiler checking, and enables compile-time printf validation for GCC, Clang, and AppleClang.
Adds a source-contract regression test that rejects nonliteral native LOG formats across first-party C++ sources and headers.
Validation