Skip to content

[C#] Taint analysis does not have flow path for non constant field of a class as its source #9728

Answered by tamasvajk
kanan1832 asked this question in Q&A
Discussion options

You must be logged in to vote

This is a great question, I had to dig into CFG and DF implementation details for the answer, and I'm not sure I have the full picture yet, but hopefully the below answers your question.

The CodeQL C# library handles instance fields differently than static or const fields. Initializers of instance fields are moved into instance constructors when the CFG is constructed. So the following sample

class C 
{
  int x = 42;

  C() { }
}

is modelled as the below in the CFG

class C
{
  int x;

  C() 
  {
    this.x = 42;
  }
}

I'm not sure about the reasons why it was implemented like this, but I assume this lets us do precise dataflow analysis in case of inheritance and virtual dispatch. Also, it…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hvitved
Comment options

@aschackmull
Comment options

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