mirror of
https://github.com/elicpeter/nyx.git
synced 2026-07-12 21:02:11 +02:00
Added Cap::DATA_EXFIL and taint fp and fn fixes on real repos (#59)
* feat: Enhance data exfiltration detection with source sensitivity gating for cookies and headers * feat: Implement cross-file data exfiltration detection with parameter-specific gate filters * feat: Add calibration tests and refine DATA_EXFIL severity scoring logic * feat: Introduce per-detector configuration for data exfiltration suppression * feat: Enhance DATA_EXFIL findings with destination field tracking in diagnostics and SARIF output * feat: Add tainted body and URL handling for data exfiltration detection * feat: Add integration tests and fixtures for DATA_EXFIL and SSRF detection in Go * feat: Add Java integration tests and fixtures for DATA_EXFIL detection across multiple HTTP clients * feat: Add synthetic externals handling for closure-captured variables in SSA * feat: Implement closure-based suppression for resource leak findings * feat: Add regression guards for shell-injection and taint propagation in for-of destructure patterns * feat: Implement constructor cap narrowing for data exfiltration detection in HTTP request builders * feat: Add gated sinks for data exfiltration detection in C and C++ using curl_easy_setopt * feat: Implement DATA_EXFIL cap parity for backwards analysis and add integration tests * feat: Add data exfiltration sinks for various languages and enhance documentation * refactor: Simplify formatting and improve readability in various files * refactor: Improve readability by simplifying conditional statements and adding clippy linting * docs: Update CHANGELOG and comments for data exfiltration features and configuration * docs: Clarify configuration instructions for data exfiltration trusted destinations * docs: Enhance comments for evidence routing logic in data exfiltration
This commit is contained in:
parent
a438886217
commit
58f1794a4e
189 changed files with 8421 additions and 383 deletions
19
tests/fixtures/go/data_exfil_http_post.go
vendored
Normal file
19
tests/fixtures/go/data_exfil_http_post.go
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// DATA_EXFIL fixture: a fixed destination URL and a Sensitive (cookie)
|
||||
// source flowing into the outbound body of `http.Post`. SSRF must NOT
|
||||
// fire (URL is hardcoded, position 0) but `Cap::DATA_EXFIL` must fire on
|
||||
// the body (position 2) — the auth cookie is exactly the cross-boundary
|
||||
// state DATA_EXFIL targets.
|
||||
//
|
||||
// Driven by `data_exfil_go_integration_tests.rs`.
|
||||
package fixture
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func leakCookie(r *http.Request) {
|
||||
c, _ := r.Cookie("session")
|
||||
body := strings.NewReader(c.Value)
|
||||
http.Post("https://analytics.internal/track", "text/plain", body)
|
||||
}
|
||||
27
tests/fixtures/go/data_exfil_map_assign.go
vendored
Normal file
27
tests/fixtures/go/data_exfil_map_assign.go
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Container-taint DATA_EXFIL: a `map[string]string` is populated with
|
||||
// Sensitive cookie values across two keys, then encoded as form data and
|
||||
// shipped as the body of an outbound `http.PostForm`. The Go SSA heap
|
||||
// model marks the map's `Elements` slot tainted on every `payload[k] =
|
||||
// ...` write; the sink-side `collect_tainted_sink_values` heap-loads
|
||||
// the same slot when checking the form-data argument, so DATA_EXFIL
|
||||
// must fire on the body channel even though the local map name itself
|
||||
// is not directly tainted by an Assign. Pairs with
|
||||
// `data_exfil_post_form.go` (single-write `url.Values` literal — no
|
||||
// container-mutation step).
|
||||
//
|
||||
// Driven by `data_exfil_go_integration_tests.rs::map_assign_data_exfil`.
|
||||
package fixture
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func leakSessionMap(r *http.Request) {
|
||||
c, _ := r.Cookie("session")
|
||||
a, _ := r.Cookie("auth")
|
||||
form := url.Values{}
|
||||
form["session"] = []string{c.Value}
|
||||
form["auth"] = []string{a.Value}
|
||||
http.PostForm("https://analytics.internal/track", form)
|
||||
}
|
||||
24
tests/fixtures/go/data_exfil_new_request_do.go
vendored
Normal file
24
tests/fixtures/go/data_exfil_new_request_do.go
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// DATA_EXFIL fixture for the two-step `http.NewRequest` → `client.Do`
|
||||
// idiom. `http.NewRequest` is modeled as a body propagator (default
|
||||
// arg → return propagation lifts body taint onto the returned
|
||||
// `*http.Request`); the outbound network call happens at
|
||||
// `http.DefaultClient.Do`, where the DATA_EXFIL gate fires on the
|
||||
// request argument.
|
||||
//
|
||||
// SSRF must NOT fire (URL is hardcoded at NewRequest's URL position) and
|
||||
// the cookie-derived body must surface DATA_EXFIL at the Do call.
|
||||
//
|
||||
// Driven by `data_exfil_go_integration_tests.rs`.
|
||||
package fixture
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func leakViaNewRequest(r *http.Request) {
|
||||
c, _ := r.Cookie("session")
|
||||
body := strings.NewReader(c.Value)
|
||||
req, _ := http.NewRequest("POST", "https://analytics.internal/track", body)
|
||||
http.DefaultClient.Do(req)
|
||||
}
|
||||
18
tests/fixtures/go/data_exfil_post_form.go
vendored
Normal file
18
tests/fixtures/go/data_exfil_post_form.go
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// DATA_EXFIL fixture: a Sensitive (header) source flowing into the form
|
||||
// payload of `http.PostForm` (arg 1, `url.Values`). The destination URL
|
||||
// is hardcoded so SSRF does not fire; only the form-data path activates
|
||||
// the body-position gate.
|
||||
//
|
||||
// Driven by `data_exfil_go_integration_tests.rs`.
|
||||
package fixture
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func leakAuthHeader(r *http.Request) {
|
||||
auth := r.Header.Get("Authorization")
|
||||
form := url.Values{"token": []string{auth}}
|
||||
http.PostForm("https://analytics.internal/track", form)
|
||||
}
|
||||
19
tests/fixtures/go/data_exfil_user_input_silenced.go
vendored
Normal file
19
tests/fixtures/go/data_exfil_user_input_silenced.go
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// DATA_EXFIL silenced regression fixture: plain user input echoed into
|
||||
// the body of an outbound `http.Post` to a fixed URL must NOT fire
|
||||
// `Cap::DATA_EXFIL`. The user already controls `r.FormValue("msg")`, so
|
||||
// surfacing it back into the request payload is not a cross-boundary
|
||||
// disclosure. Source-sensitivity gating in `ast.rs` strips the cap.
|
||||
//
|
||||
// Driven by `data_exfil_go_integration_tests.rs`.
|
||||
package fixture
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func forwardUserInput(r *http.Request) {
|
||||
msg := r.FormValue("msg")
|
||||
body := strings.NewReader(msg)
|
||||
http.Post("https://analytics.internal/track", "text/plain", body)
|
||||
}
|
||||
18
tests/fixtures/go/ssrf_url_tainted.go
vendored
Normal file
18
tests/fixtures/go/ssrf_url_tainted.go
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// SSRF regression fixture: attacker-controlled destination URL flows
|
||||
// into `http.NewRequest`'s URL position (arg 1). SSRF must fire on the
|
||||
// URL flow; DATA_EXFIL must NOT fire (the body is hardcoded `nil`).
|
||||
// Cap attribution is per-position so a tainted URL never surfaces as
|
||||
// data exfiltration.
|
||||
//
|
||||
// Driven by `data_exfil_go_integration_tests.rs`.
|
||||
package fixture
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func proxy(r *http.Request) {
|
||||
target := r.URL.Query().Get("target")
|
||||
req, _ := http.NewRequest("GET", target, nil)
|
||||
http.DefaultClient.Do(req)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue