Documentation ¶
Overview ¶
Package taint enables "taint checking", a static analysis technique for identifying attacker-controlled "sources" used in dangerous contexts "sinks".
A classic example of this is identifying SQL injections, where user controlled inputs, typically from an HTTP request, finds their way into a SQL query without using a prepared statement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrStopWalk = fmt.Errorf("taint: stop walk")
Functions ¶
Types ¶
type Result ¶
type Result struct { // Path is the specific path within a callgraph // where the source founds its way into a sink. Path callgraphutil.Path // Source type information. SourceType string // Source SSA value. SourceValue ssa.Value // Sink information. SinkType string // Sink SSA value. SinkValue ssa.Value }
Result is an individual finding from a taint check.
It contains the path within the callgraph where the source found its way into the sink, along with the source and sink type information and SSA values.
type Results ¶
type Results []Result
Results is a collection of unique findings from a taint check.
func Check ¶
Check is the primary function users of this package will use.
It returns a list of results from the callgraph, where any of the given sources found their way into any of the given sinks.
Sources is a list of functions that return user-controlled values, such as HTTP request parameters. Sinks is a list of potentially dangerous functions that should not be called with user-controlled values.
Diagram ╭───────────────────────────────────────────────────────────────╮ │ ╭────────┬──────────────╮ │ │ ▼ │ │ │ ╭───────╮ │ ╭───────────╮ ╭───────────────╮│ ╭──────────┴──────────╮ │ │ Check ├──▶ │ │ checkPath ├──▶ │ checkSSAValue ├┴─▶ │ checkSSAInstruction │ │ ╰───────╯ │ ╰───────────╯ ╰───────────────╯ ╰─────────────────────╯ │ ╰──────────────────────────────┬────────────────────────────────╯ │ ▼ ╭─────────╮ │ Results │ ╰─────────╯
This is a recursive algorithm that will traverse the callgraph to identify if any of the given sources were used to obtain the initial SSA value (v). We handle this value, depending on its type, where we "peel back" its references and relevant SSA instructions to determine if any of the given sinks were involved in the creation of the initial value.
Directories ¶
Path | Synopsis |
---|---|
Package callgraphutil implements utilities for golang.org/x/tools/go/callgraph including path searching, graph construction, printing, and more.
|
Package callgraphutil implements utilities for golang.org/x/tools/go/callgraph including path searching, graph construction, printing, and more. |
cmd
|
|
log
|
|
sql
|
|