Visitar URL original
Dataflow: Add flow state versions of isBarrierIn, isBarrierOut, and isBarrierGuard by jketema · Pull Request #8435 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20260316103516/https://github.com/github/codeql/pull/8435
Skip to content

Dataflow: Add flow state versions of isBarrierIn, isBarrierOut, and isBarrierGuard#8435

Merged
jketema merged 2 commits intogithub:mainfrom
jketema:all-the-barriers
Mar 16, 2022
Merged

Dataflow: Add flow state versions of isBarrierIn, isBarrierOut, and isBarrierGuard#8435
jketema merged 2 commits intogithub:mainfrom
jketema:all-the-barriers

Conversation

@jketema
Copy link
Contributor

@jketema jketema commented Mar 14, 2022 •

I've a use-case for isBarrierOut in my rewrite of cpp/command-line-injection, which needs a isSanitizerOut for a particular flow state. Others added for completeness.

@jketema jketema marked this pull request as ready for review March 15, 2022 08:56
@jketema jketema requested review from a team as code owners March 15, 2022 08:56
Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

I think the changes LGTM! Let's wait and hear what @hvitved says, and maybe we should also do another round of DCA? I imagine the slowdowns are fixed by e8a857d, but it would be good to make sure!

@jketema
Copy link
Contributor Author

jketema commented Mar 15, 2022 •

Not sure if it's worth doing all the DCA experiments again. I will re-do the Java one, as it's the only one that showed a slow down involving a query that uses taint tracking and/or data flow. And I'll do another attempt at a Python DCA run, which failed before it ran any queries.

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

LGTM. I have started a single-threaded DCA run for just apache__commons-compress, so let's wait for that before merging.

@hvitved
Copy link
Contributor

hvitved commented Mar 16, 2022

I have started a single-threaded DCA run for just apache__commons-compress, so let's wait for that before merging.

The run looks good, so go ahead and merge.

@jketema jketema merged commit 7a9a9d8 into github:main Mar 16, 2022
@jketema jketema deleted the all-the-barriers branch March 16, 2022 14:50
@aschackmull
Copy link
Contributor

There are a couple of (corner-)cases where this PR neglects to account for stateful in-/out-barriers. These are only checked on local value and taint steps and on jump steps. These barriers are not checked on read/store steps, nor on regular interprocedural steps. Unfortunately, fixing this won't be a clean addition, so I'm not sure whether it's worth fixing, or whether perhaps the use-case should rather be checked to see if the regular out-barrier would have been sufficient (which would allow us to revert stateful in-/out-barriers).
Another relatively minor omission is that this PR incorrectly handles the interplay between regularly defined sources/sinks (which implicitly use the default state), and partial barriers at those nodes using exactly the default state.

@jketema
Copy link
Contributor Author

jketema commented Apr 4, 2022

@aschackmull Thanks. Is this easy for you to address, or should we have a look together?

@aschackmull
Copy link
Contributor

The easy way for me to address this is to remove predicate isBarrierIn(Node node, FlowState state) and predicate isBarrierOut(Node node, FlowState state), so the question is whether you can do without those two predicates? Fully supporting those two predicates is going to be messy so that's my preferred solution.

@jketema
Copy link
Contributor Author

jketema commented Apr 5, 2022

Unfortunately predicate isBarrierOut(Node node, FlowState state) was my main reason for adding this in the first place. See here. If you think there's another solution that might work there, I'm up for it.

@aschackmull
Copy link
Contributor

Is it important for flow in the ConcatState to be able to continue after reaching a sink? Because otherwise you could simply use

  override predicate isSanitizerOut(DataFlow::Node node) {
    isSink(node, _) // Prevent duplicates along a call chain, since `shellCommand` will include wrappers
  }

instead.

@jketema
Copy link
Contributor Author

jketema commented Apr 5, 2022

Is it important for flow in the ConcatState to be able to continue after reaching a sink?

That might lead to false negatives, but I haven't looked if those occur in practise (I can do that if you'd like).

@owen-mc owen-mc changed the title Add flow state versions of isBarrierIn, isBarrierOut, and isBarrierGuard Dataflow: Add flow state versions of isBarrierIn, isBarrierOut, and isBarrierGuard Nov 2, 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.

5 participants