Skip to content

cpp: model BDE bdlbb::Blob byte-buffer taint flow - #13

Open
anurag6569201 wants to merge 1 commit into
qa/agent-github-codeql/pr-13-22455/basefrom
qa/agent-github-codeql/pr-13-22455/head
Open

anurag6569201 wants to merge 1 commit into
qa/agent-github-codeql/pr-13-22455/basefrom
qa/agent-github-codeql/pr-13-22455/head

Conversation

@anurag6569201

Copy link
Copy Markdown

Add flow summaries for the BDE segmented byte buffer BloombergLP::bdlbb::Blob so taint reaches a blob's payload bytes:

  • Accessor chain: Blob::buffer taints the returned BlobBuffer, and BlobBuffer::data/buffer taint the bytes.
  • bdlbb::BlobUtil::copy and getContiguousRangeOrCopy propagate taint between a blob and a flat buffer in both directions.

This unblocks blob-carried sources such as bmqa::Message::getData, whose payload was previously stranded on the opaque Blob object. Not a duplicate; the bdlbb namespace had no coverage. Verified with a BloombergLP::bdlbb-shaped stub in the dataflow external-models harness.

Source merge-base: b756a08cf59743b7e8483622202440e012a90662
Source head: 9559357bc637f7d5531aeb3152ec472fb61aa3f3

@shipwright-agent

Copy link
Copy Markdown

✅ Shipwright · Approve

Recommendation: approve PR #13 · Tier T2
Checks: 0 total · 0 needing attention

Next step: ready to merge.

Findings (6)

  • HIGH The model file uses empty signatures for Blob::buffer, BlobBuffer::data, BlobBuffer::buffer, and getContiguousRangeOrCopy. · cpp/ql/lib/ext/bdlbb.model.yml:8
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The model for BlobUtil::getContiguousRangeOrCopy has two entries with the same empty signature, one mapping Argument[*1] to Argument[*0] and one mapping Argument[*1] to ReturnValue · cpp/ql/lib/ext/bdlbb.model.yml:13
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The BlobUtil::copy overload taking (char *,const Blob &,int,int) is modeled as Argument[*1] -> Argument[*0] with no length or position constraints. · cpp/ql/lib/ext/bdlbb.model.yml:12
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The model marks BlobUtil::copy(Blob *,int,const char *,int) as Argument[*2] -> Argument[*0] with no sanitization or length validation. · cpp/ql/lib/ext/bdlbb.model.yml:16
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • LOW The test stubs declare BlobBuffer::buffer() returning bsl::shared_ptr<char>&, but the model comment says the get() step comes from the built-in smart pointer model. · cpp/ql/test/library-tests/dataflow/external-models/bdlbb.cpp:70
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • LOW The validatemodels output now contains three new 'Dubious signature' warnings for the BlobUtil signatures. · cpp/ql/test/library-tests/dataflow/external-models/validatemodels.expected:373
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

Fireworks usage: 18,913 input · 735 output · 19,648 total tokens · $0.0046 · 13s · 0 fix iteration(s)

Open the Shipwright check for full evidence and the audit bundle. Use /shipwright rerun to verify again.

pack: codeql/cpp-all
extensible: summaryModel
data: # namespace, type, subtypes, name, signature, ext, input, output, kind, provenance
# Accessor chain

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

The model file uses empty signatures for Blob::buffer, BlobBuffer::data, BlobBuffer::buffer, and getContiguousRangeOrCopy.

Impact: The model file uses empty signatures for Blob::buffer, BlobBuffer::data, BlobBuffer::buffer, and getContiguousRangeOrCopy. This makes the model match any overload or future overload with the same name, and gives a reader no way to tell which API surface is actually covered without cross-referencing the test stubs.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

- ["BloombergLP::bdlbb", "BlobBuffer", true, "data", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
- ["BloombergLP::bdlbb", "BlobBuffer", true, "buffer", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
# BlobUtil read-out
- ["BloombergLP::bdlbb", "BlobUtil", true, "copy", "(char *,const Blob &,int,int)", "", "Argument[*1]", "Argument[*0]", "taint", "manual"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

The model for BlobUtil::getContiguousRangeOrCopy has two entries with the same empty signature, one mapping Argument[*1] to Argument[*0] and one mapping Argument[*1] to ReturnValue

Impact: The model for BlobUtil::getContiguousRangeOrCopy has two entries with the same empty signature, one mapping Argument[*1] to Argument[*0] and one mapping Argument[1] to ReturnValue[]. If the real function returns a pointer into the blob when the buffer is contiguous and copies into dstBuffer otherwise, the unconditional Argument[*1] -> Argument[*0] summary will propagate taint to dstBuffer even when the function…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

- ["BloombergLP::bdlbb", "Blob", true, "buffer", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
- ["BloombergLP::bdlbb", "BlobBuffer", true, "data", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
- ["BloombergLP::bdlbb", "BlobBuffer", true, "buffer", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
# BlobUtil read-out

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

The BlobUtil::copy overload taking (char *,const Blob &,int,int) is modeled as Argument[*1] -> Argument[*0] with no length or position constraints.

Impact: The BlobUtil::copy overload taking (char *,const Blob &,int,int) is modeled as Argument[*1] -> Argument[*0] with no length or position constraints. A caller that copies only a zero-length or out-of-range slice will still have the entire destination buffer marked tainted, which can create misleading flows in code that partially initializes a buffer.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

- ["BloombergLP::bdlbb", "BlobUtil", true, "copy", "(char *,const Blob &,int,int)", "", "Argument[*1]", "Argument[*0]", "taint", "manual"]
- ["BloombergLP::bdlbb", "BlobUtil", true, "getContiguousRangeOrCopy", "", "", "Argument[*1]", "Argument[*0]", "taint", "manual"]
- ["BloombergLP::bdlbb", "BlobUtil", true, "getContiguousRangeOrCopy", "", "", "Argument[*1]", "ReturnValue[*]", "taint", "manual"]
# BlobUtil write-in

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

The model marks BlobUtil::copy(Blob *,int,const char *,int) as Argument[*2] -> Argument[*0] with no sanitization or length validation.

Impact: The model marks BlobUtil::copy(Blob *,int,const char *,int) as Argument[*2] -> Argument[*0] with no sanitization or length validation. This treats any caller-supplied source buffer as fully tainted into the destination blob, which is appropriate for taint tracking but will flag every write path, including internal buffer initialization, as attacker-controlled unless downstream models add sanitizers.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

sink(*p); // $ ir
}

// The get() step comes from the built-in smart pointer model, not from bdlbb.model.yml.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · LOW

The test stubs declare BlobBuffer::buffer() returning bsl::shared_ptr<char>&, but the model comment says the get() step comes from the built-in smart pointer model.

Impact: The test stubs declare BlobBuffer::buffer() returning bsl::shared_ptr<char>&, but the model comment says the get() step comes from the built-in smart pointer model. A new contributor cannot tell from the test file alone why the shared_ptr path is expected to work or whether the non-const overload is intentionally covered.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

| Dubious signature "(BN_MONT_CTX *,const BIGNUM *,int,const unsigned char *,size_t,uint32_t,uint32_t)" in summary model. |
| Dubious signature "(BN_RECP_CTX *,const BIGNUM *,BN_CTX *)" in summary model. |
| Dubious signature "(BUF_MEM *,size_t)" in summary model. |
| Dubious signature "(Blob *,int,const Blob &,int,int)" in summary model. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · LOW

The validatemodels output now contains three new 'Dubious signature' warnings for the BlobUtil signatures.

Impact: The validatemodels output now contains three new 'Dubious signature' warnings for the BlobUtil signatures. These are expected for abbreviated C++ signatures, but they add noise to the validation baseline and should be acknowledged or suppressed so future real signature errors are not lost among expected warnings.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

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

Successfully merging this pull request may close these issues.

1 participant