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

C++: Add MaD models for SysAllocString and friends #18463

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

MathiasVP
Copy link
Contributor

The lack of these models were causing some false negatives at Microsoft.

@Copilot Copilot bot review requested due to automatic review settings January 9, 2025 17:34
@MathiasVP MathiasVP requested a review from a team as a code owner January 9, 2025 17:34

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 5 changed files in this pull request and generated no comments.

Files not reviewed (4)
  • cpp/ql/test/library-tests/dataflow/external-models/flow.expected: Language not supported
  • cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected: Language not supported
  • cpp/ql/test/library-tests/dataflow/taint-tests/taint.cpp: Language not supported
  • cpp/ql/test/library-tests/dataflow/taint-tests/test_mad-signatures.expected: Language not supported

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

@github-actions github-actions bot added the C++ label Jan 9, 2025
@MathiasVP MathiasVP added no-change-note-required This PR does not need a change note and removed no-change-note-required This PR does not need a change note labels Jan 9, 2025
Copy link
Contributor

@redsun82 redsun82 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +7 to +8
- ["", "", False, "SysAllocStringByteLen", "", "", "Argument[*0]", "ReturnValue[*]", "value", "manual"]
- ["", "", False, "SysAllocStringLen", "", "", "Argument[*0]", "ReturnValue[*]", "value", "manual"]
Copy link
Contributor

Choose a reason for hiding this comment

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

These two presumably can cut the tail of the string passed in as an argument (when the passed length is too short). I assume we still consider that value flow (although part of the data has gone missing)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. We model that somewhat inconsistency across different models. For example, strncpy is currently modeled as taint because the length argument could mean that we only did a partial copy. In practice, I have a feeling that most of these length-bounded functions are used simply as defensive programming and do provide full copies in most cases. So nowadays I tend to lean towards modeling them as value-preserving.

@MathiasVP MathiasVP merged commit a35dc7e into github:main Jan 10, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants