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

[dataflow] missing taint path when two dataflow edges reaches one node #4470

Closed
d1tto opened this issue Apr 18, 2024 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@d1tto
Copy link
Contributor

d1tto commented Apr 18, 2024

Describe the bug

<?php
$cats = $_POST['xxxxxxxxxx'];
$k = $cats;
$v = $cats;
$k = process("a", "b", $k);
$output = $k . $v;
echo $output;

In this example, there should be two taint paths to the echo call, while joern outputs only one:

_______________________________________________________________________________
| nodeType   | tracked                      | lineNumber| method   | file      |
|==============================================================================|
| Call       | $cats = $_POST["xxxxxxxxxx"] | 4         | <global> | index.php |
| Identifier | $cats = $_POST["xxxxxxxxxx"] | 4         | <global> | index.php |
| Identifier | $k = $cats                   | 5         | <global> | index.php |
| Identifier | $k = $cats                   | 5         | <global> | index.php |
| Identifier | process("a","b",$k)          | 7         | <global> | index.php |
| Call       | process("a","b",$k)          | 7         | <global> | index.php |
| Identifier | $k = process("a","b",$k)     | 7         | <global> | index.php |
| Identifier | $k . $v                      | 8         | <global> | index.php |
| Call       | $k . $v                      | 8         | <global> | index.php |
| Identifier | $output = $k . $v            | 8         | <global> | index.php |
| Identifier | echo $output                 | 9         | <global> | index.php |
| Call       | echo $output                 | 9         | <global> | index.php |

To Reproduce

  1. set $_POST['xxx'] as source node
  2. set echo call as sink node
  3. run reachablebyFlows

Expected behavior

Two taint paths, from $k to $output and $v to $output

Desktop (please complete the following information):

  • Windows
  • latest joern-dataflowengine
  • jdk17
@d1tto d1tto added the bug Something isn't working label Apr 18, 2024
@d1tto
Copy link
Contributor Author

d1tto commented Apr 18, 2024

It seems that the problem is caused by the deduplicateFinal method in Engine class. After I remoce this method, the result is complete.

_________________________________________________________________________
| nodeType   | tracked                      | line| method   | file      |
|========================================================================|
| Call       | $cats = $_POST["categories"] | 4   | <global> | index.php |
| Identifier | $cats = $_POST["categories"] | 4   | <global> | index.php |
| Identifier | $k = $cats                   | 5   | <global> | index.php |
| Identifier | $k = $cats                   | 5   | <global> | index.php |
| Identifier | process("a","b",$k)          | 7   | <global> | index.php |
| Call       | process("a","b",$k)          | 7   | <global> | index.php |
| Identifier | $k = process("a","b",$k)     | 7   | <global> | index.php |
| Identifier | $k . $v                      | 8   | <global> | index.php |
| Call       | $k . $v                      | 8   | <global> | index.php |
| Identifier | $output = $k . $v            | 8   | <global> | index.php |
| Identifier | echo $output                 | 9   | <global> | index.php |
| Call       | echo $output                 | 9   | <global> | index.php |
_________________________________________________________________________
| nodeType   | tracked                      | line| method   | file      |
|========================================================================|
| Call       | $cats = $_POST["categories"] | 4   | <global> | index.php |
| Identifier | $cats = $_POST["categories"] | 4   | <global> | index.php |
| Identifier | $v = $cats                   | 6   | <global> | index.php |
| Identifier | $v = $cats                   | 6   | <global> | index.php |
| Identifier | $k . $v                      | 8   | <global> | index.php |
| Identifier | $k . $v                      | 8   | <global> | index.php |
| Call       | $k . $v                      | 8   | <global> | index.php |
| Identifier | $output = $k . $v            | 8   | <global> | index.php |
| Identifier | echo $output                 | 9   | <global> | index.php |
| Call       | echo $output                 | 9   | <global> | index.php |
_________________________________________________________________________
| nodeType   | tracked                      | line| method   | file      |
|========================================================================|
| Call       | $cats = $_POST["categories"] | 4   | <global> | index.php |
| Identifier | $cats = $_POST["categories"] | 4   | <global> | index.php |
| Identifier | $v = $cats                   | 6   | <global> | index.php |
| Identifier | $v = $cats                   | 6   | <global> | index.php |
| Identifier | $k . $v                      | 8   | <global> | index.php |
| Call       | $k . $v                      | 8   | <global> | index.php |
| Identifier | $output = $k . $v            | 8   | <global> | index.php |
| Identifier | echo $output                 | 9   | <global> | index.php |
| Call       | echo $output                 | 9   | <global> | index.php |

I read the code and found the path of the same source and sink, which takes the longest path if only one. Is it possible to provide a config option that provides the complete result to the user

@d1tto d1tto closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant