Visitar URL original
C++: Upgrade cpp/cleartext-storage-buffer by geoffw0 · Pull Request #7742 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20260624064021/https://github.com/github/codeql/pull/7742
Skip to content

C++: Upgrade cpp/cleartext-storage-buffer#7742

Merged
MathiasVP merged 6 commits into
github:mainfrom
geoffw0:clrtxt6
Jan 27, 2022
Merged

C++: Upgrade cpp/cleartext-storage-buffer#7742
MathiasVP merged 6 commits into
github:mainfrom
geoffw0:clrtxt6

Conversation

@geoffw0

@geoffw0 geoffw0 commented Jan 25, 2022

Copy link
Copy Markdown
Contributor

Resolves a bit more of the inconsistency between cpp/cleartext-transmission, cpp/cleartext-storage-file and cpp/cleartext-storage-buffer by upgrading the third one from security to AST taint flow.

We still use the old security library's isUserInput to identify inputs, that could be upgraded as well but may have a bigger impact on results.

LGTM diff query: https://lgtm.com/query/6710910426361157574/ (sparse results, no differences)

@geoffw0 geoffw0 added the C++ label Jan 25, 2022
@geoffw0 geoffw0 requested a review from a team as a code owner January 25, 2022 15:07
import semmle.code.cpp.security.SensitiveExprs
import TaintedWithPath
import semmle.code.cpp.security.Security
import semmle.code.cpp.dataflow.TaintTracking

@MathiasVP MathiasVP Jan 25, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is moving from IR taint tracking to AST taint tracking, which is a bit sad. Could we replace this with semmle.code.cpp.ir.dataflow.TaintTracking?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah that's interesting, I thought the the security lib / default taint tracking used AST taint.

I'll update it to be IR-based...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fantastic! Here's a quick summary:

  • semmle.code.cpp.security.TaintTracking is an alias for semmle.code.cpp.ir.dataflow.DefaultTaintTracking (which is an IR taint tracking library that uses an IR DataFlow configuration)
  • semmle.code.cpp.dataflow.TaintTracking is an AST taint tracking library
  • semmle.code.cpp.ir.dataflow.TaintTracking is an IR taint tracking library built on an IR TaintTracking configuration. By now I think this library should mostly be superior to semmle.code.cpp.dataflow.TaintTracking, but there are a few limitations that mostly shouldn't matter in practice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've just done two things:

  • put it back on IR taint tracking, but no longer via relying on DefaultTaintTracking. This is probably slightly untidier than what we started with, but opens the possibility to replace security library isUserInput with modern flow sources (which I should look at later today...)
  • I've also added to QLDoc at the top of two of the library files you described above. That should help us (and others) remember which is which in future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've updated it to use FlowSource, which is cleaner and appears to give better textual explanations of the source.

@MathiasVP MathiasVP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Are the results still the expected set of results?

ToBufferConfiguration() { this = "ToBufferConfiguration" }

override predicate isSource(DataFlow::Node source) { isUserInput(source.asExpr(), _) }
override predicate isSource(DataFlow::Node source) { isUserInput(exprForNode(source), _) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we get the same results if we use source instanceof FlowSource? Then we don't need this ugly exprForNode (as FlowSource.getSourceType can be used instead of isUserInput to get the taintCause). Oh, you did exactly that in the last commit. Excellent!

@geoffw0

geoffw0 commented Jan 27, 2022 •

Copy link
Copy Markdown
Contributor Author

Yep, results on the test and a very ugly LGTM diff are the same. I was hoping to get some new ones, but there you go.

@MathiasVP MathiasVP merged commit b3f4357 into github:main Jan 27, 2022
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.

2 participants