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

[dataflowengineoss] Fix missing taint nodes on conditional operator #4939

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

d1tto
Copy link
Contributor

@d1tto d1tto commented Sep 21, 2024

Take the code as an example

<?= isset($_GET['added_after']) ? htmlspecialchars($_GET['added_after']) : '' ?>

the expected taint flow is

  • $_GET['added_after']
  • htmlspecialchars($_GET['added_after']) // missing in current joern
  • isset($_GET['added_after']) ? htmlspecialchars($_GET['added_after']) : ''
  • echo isset($_GET['added_after']) ? htmlspecialchars($_GET['added_after']) : ''

However, due to the incomplete semantics for conditional, the htmlspecialchars($_GET['added_after']) call node is marked as invisible in here:

// Engine.scala
  private def elemForEdge(e: Edge, callSiteStack: List[Call] = List(), strict: Boolean)(implicit
    semantics: Semantics
  ): Option[PathElement] = {
    // in this case, 
    // curNode is `isset($_GET['added_after']) ? htmlspecialchars($_GET['added_after']) : ''`
    // parNode is `htmlspecialchars($_GET['added_after'])`
    curNode match {
      // ...
      case childNode: Expression =>
        parNode match {
          case parentNode: Expression =>
            val parentNodeCall = parentNode.inCall.l
            val sameCallSite   = parentNode.inCall.l == childNode.start.inCall.l
            val visible = if (sameCallSite) {
              // ...
            } else {
              parentNode.isDefined // here
            }
            // ...
        }
    }
  }

@d1tto d1tto marked this pull request as draft September 22, 2024 09:14
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