Skip to content

Help: how to ensure a secure PointerFieldAccess chain #16842

Answered by MathiasVP
mindcrunch4u asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mindcrunch4u,

I'm not sure if you really need a taint-tracking configuration for your query. The following snippet (which just uses a GuardCondition) detects all the problematic cases in your example:

/**
 * @kind problem
 */

import semmle.code.cpp.controlflow.Guards
import semmle.code.cpp.ir.ValueNumbering

/** Holds if `instr` is guarded to be non-null */
predicate isNullGuarded(Instruction instr) {
  any(IRGuardCondition gc).ensuresEq(valueNumber(instr).getAUse(), 0, instr.getBlock(), false)
}

from LoadInstruction load, Instruction qualifier, PointerFieldAccess pfa
where
  // The load is from a load of a pointer field access
  load.getUnconvertedResultExpression() = pfa and
  qua…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by mindcrunch4u
Comment options

You must be logged in to vote
4 replies
@mindcrunch4u
Comment options

@MathiasVP
Comment options

@MathiasVP
Comment options

@mindcrunch4u
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants