Compare commits

..
Author SHA1 Message Date
dependabot[bot] 234aa3fb5f deps(docker): bump python from 935c3c5 to 44cf179
Bumps python from `935c3c5` to `44cf179`.

---
updated-dependencies:
- dependency-name: python
  dependency-version: 3.12-slim-bookworm
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-30 20:38:34 +00:00
6 changed files with 7 additions and 464 deletions
+6 -2
View File
@@ -66,8 +66,12 @@ The execution-scope gap and its remediation were tracked in public before the No
- **`traffic_get` keeps compressed binary responses encoded** (follow-up to #606): the decoded view judged a body as binary only by a NUL byte in its first 512 bytes, so a gzip `application/pdf` without one was shown as text. It now uses the response `Content-Type` as well, the same check the body index applies. The response head is read before the body, so an exchange without a `Content-Encoding` no longer loads its spilled blobs, and the request blob is never loaded.
- **`traffic_search` host matching**: a port search such as `host:8443` matched any capture of that host whose URL quoted `host:8443` in its query string (`?next=http://host:8443/`, typical of open-redirect and SSRF probes), because the authority prefix was not anchored to the scheme. It is now anchored to `http`, `https`, `ws` and `wss`. The recorded host keeps the client's case while the search is lowercased, so a capture of `https://Mixed.Example.com/` was not found by any host search; the comparison now ignores case. A compressed body with a bad checksum or trailing garbage now keeps the text decoded before the error instead of dropping out of the index, and the store directory guard on host delete ignores case for case-insensitive filesystems.
- **Browser capture keeps a bounded request map**: unfinished debugger requests are capped at 500, and a request that fails to load is dropped instead of waiting for eviction. A stored body longer than 256K JavaScript characters is cut and marked `[truncated by extension]`. That count is UTF-16 code units, not bytes; the server still enforces its byte cap on ingest.
- **The capture proxy no longer holds a response while indexing it** (#542): recording wrote the trigram full-text index of each body (up to 4 MiB) before the client got its response, so a 1 MB script added about 160 ms to its own response. The index text is now committed with the exchange into `ex_fts_pending` and indexed by a background worker; with the indexer idle, recording a 1 MiB script takes about 5 ms. Under a burst of large bodies a recording can still wait behind the entry being indexed, since both need the recorder's write lock. Body searches wait (up to 30 s) for entries queued before them, so they still find every exchange recorded before the search. Entries left by a crash or a stop are indexed on the next start, and shutdown no longer drains the queue. An entry whose exchange was deleted after it was queued is dropped.
- **Browser capture keeps a bounded request map**: unfinished debugger requests are capped at 500, and a stored request body is cut at the same 256 KiB limit as ingest.
- **The capture proxy no longer holds a response while indexing it** (#542): recording wrote the trigram full-text index of each body (up to 4 MiB) before the client got its response, under the recorder's global lock, so a 1 MB script added about 160 ms to its own response and to every response recorded behind it. The index is now written by a background worker. Body searches wait for entries queued before them, so they still find every exchange recorded before the search. An entry whose exchange was deleted in the meantime is dropped.
- **The capture proxy no longer holds a response while indexing it** (#542): recording wrote the trigram full-text index of each body (up to 4 MiB) before the client got its response, so a 1 MB script added about 160 ms to its own response. The index text is now committed with the exchange into `ex_fts_pending` and indexed by a background worker; with the indexer idle, recording a 1 MiB script takes about 5 ms. Under a burst of large bodies a recording can still wait behind the entry being indexed, since both need the recorder's write lock. Body searches wait (up to 30 s) for entries queued before them, so they still find every exchange recorded before the search. Entries left by a crash or a stop are indexed on the next start, and shutdown no longer drains the queue.
- **Host-filtered traffic searches no longer sort a host's whole history**: the capture index had `host` and `ts` indexed separately, so `traffic_search` and `Search` (`WHERE host=? ORDER BY ts DESC`) sorted every exchange of the host to return the newest few, and the host picker (`Hosts()`, polled every 5 s) scanned the table. A `(host, ts)` index replaces the `host` one. With 45k exchanges on one host, a host search drops from about 42 ms to 0.04 ms and the host list from 20 ms to 8 ms. The traffic page's own list (`Page()`) is unchanged. The index is built once, synchronously, on the first start after upgrading; on a store with millions of exchanges that delays startup and needs temporary disk space about the size of the index.
- **Traffic host lists no longer sort a host's whole history**: the capture index had `host` and `ts` indexed separately, so `traffic_search` and the traffic page's host filter sorted every exchange of the host to return the newest few, and the host picker (polled every 5 s) scanned the table. A `(host, ts)` index replaces the `host` one. With 45k exchanges on one host, a host search drops from about 42 ms to 0.04 ms and the host list from 20 ms to 8 ms.
- **Traffic host delete leaves the store directories in place**: a requested host whose sanitized name is `_index`, `_blobs`, `_ca`, `_delete_staging`, `.`, or `..` is not used as a directory. Those paths are the capture index, the blob store, the MITM CA, the delete staging area, or the traffic directory itself. Index rows for that host are still removed.
- **The SOCKS5 listener refuses non-loopback clients for every auth method**: username/password was offered to any client and accepted any credentials, so a remote client got past the loopback-only rule for no-auth by offering method `0x02`. Credentials are still not verified (the username carries only the pace marker), so both methods are now accepted from loopback clients only; binding `ARTEX_SOCKS5_ADDR` to a non-loopback address no longer exposes an open proxy.
- **Request bodies labelled multipart are capped**: the 32 MiB body cap skipped any request with a multipart `Content-Type`, so a JSON handler reading the body directly could be sent an unbounded body. Multipart bodies now get an upload-sized cap (the largest limit an upload handler sets).
- **The `traffic_search` host example no longer names a real IP**: the tool description shown to the model used a routable third-party address; it now uses `192.0.2.10` (RFC 5737).
@@ -76,6 +80,7 @@ The execution-scope gap and its remediation were tracked in public before the No
- **Asset insert applies the JSON body cap**: `POST /api/assets` decodes through the shared JSON limit, including a `multipart/` request that the upload middleware leaves uncapped. A body over the cap is rejected before the database is touched.
- **The LLM connection test honours the output-cap field name**: `POST /api/llm/test` never read a profile's `max_tokens_field`, so the Test button always sent the cap as `max_tokens`. An OpenAI reasoning model (o-series, GPT-5) rejects that with `unsupported_parameter` and a 400, so a profile set to `max_completion_tokens` failed the test even though conversations with it worked. The test now resolves the field from the form, falling back to the stored profile for the list-view test button, and normalises it the same way a profile save does (only the openai format with `max_completion_tokens` is kept).
- **Skill endpoints no longer return database driver text**: a failure loading skill usage, missing-skill stats, or skill visibility is logged on the server and the client receives a fixed message.
- **Skill endpoints no longer return database driver text**: a failure loading skill usage or missing-skill stats is logged on the server and the client receives a fixed message.
- **Hook `ReplaceAll` counts against the memory budget before it runs**: `strings.ReplaceAll`, `bytes.ReplaceAll` and `regexp.ReplaceAllString` built their result first and charged it after, so a hook that repeats a long string over many matches allocated far past the 4 MiB budget. With 1 MiB replaced into each byte of 1 MiB, the runtime asked for 1 TiB and the server process exited with `fatal error: runtime: out of memory`, in a dry run as on live traffic. The size of the result is now charged before it is built, and the hook stops with the memory limit.
- **Agent list tools cap their page size**: `list_worker_traces`, `list_assets`, and `list_untested_assets` clamp a model-supplied limit or page size to 100, and clamp the page number and offset. A limit is no longer used raw as a slice capacity or a SQL page size.
- **Legacy MCP SSE refuses an overlong line**: the endpoint announcement and the legacy event reader stop a line that grows past the existing JSON-RPC buffer cap, instead of buffering it with an unbounded read.
@@ -97,7 +102,6 @@ The execution-scope gap and its remediation were tracked in public before the No
- **Uploads do not follow a symlink**: chat and workspace uploads `Lstat` the destination and refuse to write when it is already a symlink. A dangling link is no longer treated as a free name.
- **Hardening follow-up for the upload and capture fixes**: existing spill blob directories and files are tightened on startup, hook `range` charges 32 bytes per pair, and uploads open with `O_NOFOLLOW` on Unix. The Windows upload path keeps the `Lstat` check.
- **Docker Compose database passwords with URL-special characters**: `docker-compose.yml` no longer pastes `POSTGRES_PASSWORD` into `ARTEX_PG_DSN`. The server builds the URL from `ARTEX_PG_HOST`, `ARTEX_PG_PORT`, `ARTEX_PG_USER`, `ARTEX_PG_PASSWORD`, `ARTEX_PG_DBNAME` and `ARTEX_PG_SSLMODE`, percent-encoding the user and password, so `/`, `?`, `%`, `@`, `:` and spaces connect. An explicit `ARTEX_PG_DSN` still wins and is not rewritten. `ARTEX_PG_PASSWORD` is removed from the environment with the other startup secrets (#450).
- **A CORS proof must use a browser-serialized origin and a matching response**: a finding could reach `verified` when the bound exchange carried an `Origin` header no browser sends, or a response that never authorized that origin, because verification only checked that the quoted body was present. CORS-class findings now parse the bound request and response heads, require an RFC 6454 serialized origin, and require `Access-Control-Allow-Origin` to be that exact origin or `*` without credentials; otherwise the finding stays `unverified` with the reason in the verification note. The check reads the finding's own class, so other verification paths are unchanged (#720).
### Other changes since 0.6.0
+1 -1
View File
@@ -160,7 +160,7 @@ RUN set -eux; \
test "$count" -gt 10000
# ---------------------------------------------------------------- runtime ---
FROM python:3.12-slim-bookworm@sha256:935c3c5b12357a7e10caa9c1e6ca5692344d97cf229832ef584be2cec9fc03df
FROM python:3.12-slim-bookworm@sha256:44cf1793efa7c7a476bb0f2cff81443f4a072c90c1cb127e2924933daa3e8c64
ARG TARGETARCH
ARG ARTEX_VERSION=dev
ARG ARTEX_REVISION=
-275
View File
@@ -1,275 +0,0 @@
package db
import (
"bufio"
"fmt"
"net/http"
"net/netip"
"net/textproto"
"strconv"
"strings"
)
// ValidateBrowserOrigin validates an Origin header value as a browser origin
// serialized by RFC 6454 / the Fetch standard. The opaque origin "null" is
// valid and is handled separately from network origins. The Fetch grammar is
// intentionally stricter than a general URL parser: browser serialization is
// lowercase ASCII, uses canonical IP literals, and omits default ports.
func ValidateBrowserOrigin(raw string) error {
if raw == "" {
return fmt.Errorf("origin is empty")
}
if raw == "null" {
return nil
}
for i := 0; i < len(raw); i++ {
if raw[i] < 0x21 || raw[i] > 0x7e {
return fmt.Errorf("origin contains a non-ASCII or whitespace byte")
}
}
separator := strings.Index(raw, "://")
if separator <= 0 {
return fmt.Errorf("origin must be a serialized origin")
}
scheme := raw[:separator]
if !validSerializedScheme(scheme) {
return fmt.Errorf("origin scheme is not a lowercase serialized scheme")
}
authority := raw[separator+3:]
if authority == "" {
return fmt.Errorf("origin host is empty")
}
host, port, hasPort, err := splitSerializedAuthority(authority)
if err != nil {
return err
}
if err := validateSerializedHost(host); err != nil {
return err
}
if hasPort {
if err := validateSerializedPort(port); err != nil {
return err
}
if port == defaultOriginPort(scheme) {
return fmt.Errorf("origin must omit the default port")
}
}
return nil
}
func validSerializedScheme(scheme string) bool {
if scheme == "" || scheme[0] < 'a' || scheme[0] > 'z' {
return false
}
for i := 1; i < len(scheme); i++ {
c := scheme[i]
if (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '+' && c != '-' && c != '.' {
return false
}
}
return true
}
func splitSerializedAuthority(authority string) (host, port string, hasPort bool, err error) {
if strings.HasPrefix(authority, "[") {
close := strings.IndexByte(authority, ']')
if close < 0 {
return "", "", false, fmt.Errorf("origin IPv6 host is not bracketed")
}
rest := authority[close+1:]
if rest != "" && rest[0] != ':' {
return "", "", false, fmt.Errorf("origin has an invalid authority")
}
if rest != "" {
return authority[1:close], rest[1:], true, nil
}
return authority[1:close], "", false, nil
}
if strings.ContainsAny(authority, "[]/@\\/?#") {
return "", "", false, fmt.Errorf("origin authority contains an invalid character")
}
if colon := strings.IndexByte(authority, ':'); colon >= 0 {
return authority[:colon], authority[colon+1:], true, nil
}
return authority, "", false, nil
}
func validateSerializedHost(host string) error {
if host == "" {
return fmt.Errorf("origin host is empty")
}
if strings.Contains(host, ":") {
addr, err := netip.ParseAddr(host)
if err != nil || !addr.Is6() || addr.String() != host {
return fmt.Errorf("origin IPv6 host is not canonical")
}
return nil
}
for _, label := range strings.Split(host, ".") {
if label == "" || !isSerializedDomainLabel(label) {
return fmt.Errorf("origin host is not a serialized domain")
}
}
return nil
}
func isSerializedDomainLabel(label string) bool {
if !isLowerAlphaNum(label[0]) || !isLowerAlphaNum(label[len(label)-1]) {
return false
}
for i := 1; i < len(label)-1; i++ {
if !isLowerAlphaNum(label[i]) && label[i] != '-' {
return false
}
}
return true
}
func isLowerAlphaNum(c byte) bool {
return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')
}
func validateSerializedPort(port string) error {
if port == "" || len(port) > 5 || (len(port) > 1 && port[0] == '0') {
return fmt.Errorf("origin port is not a serialized port")
}
for i := 0; i < len(port); i++ {
if port[i] < '0' || port[i] > '9' {
return fmt.Errorf("origin port is not a serialized port")
}
}
n, err := strconv.ParseUint(port, 10, 16)
if err != nil || n > 65535 {
return fmt.Errorf("origin port is out of range")
}
return nil
}
func defaultOriginPort(scheme string) string {
switch scheme {
case "http", "ws":
return "80"
case "https", "wss":
return "443"
case "ftp":
return "21"
default:
return ""
}
}
// ValidateCORSProof validates the request Origin and the response CORS
// headers that claim to authorize it.
func ValidateCORSProof(reqHeaders, respHeaders http.Header) error {
origin, err := singleHeaderValue(reqHeaders, "Origin")
if err != nil {
return fmt.Errorf("invalid Origin header: %w", err)
}
if err := ValidateBrowserOrigin(origin); err != nil {
return fmt.Errorf("invalid Origin header: %w", err)
}
acao, err := singleHeaderValue(respHeaders, "Access-Control-Allow-Origin")
if err != nil {
return fmt.Errorf("invalid Access-Control-Allow-Origin header: %w", err)
}
acao = strings.TrimSpace(acao)
if acao == "" {
return fmt.Errorf("Access-Control-Allow-Origin is empty")
}
acac, err := singleHeaderValueOptional(respHeaders, "Access-Control-Allow-Credentials")
if err != nil {
return fmt.Errorf("invalid Access-Control-Allow-Credentials header: %w", err)
}
if acao == "*" && strings.EqualFold(strings.TrimSpace(acac), "true") {
return fmt.Errorf("wildcard Access-Control-Allow-Origin is invalid with credentials")
}
if acao != "*" && acao != origin {
return fmt.Errorf("Access-Control-Allow-Origin %q does not match Origin %q", acao, origin)
}
return nil
}
// ValidateCORSProofHeads parses the raw request and response head blocks used
// by traffic evidence and validates their CORS headers.
func ValidateCORSProofHeads(reqHead, respHead string) error {
reqHeaders, err := parseStoredHeaders(reqHead)
if err != nil {
return fmt.Errorf("invalid request head: %w", err)
}
respHeaders, err := parseStoredHeaders(respHead)
if err != nil {
return fmt.Errorf("invalid response head: %w", err)
}
return ValidateCORSProof(reqHeaders, respHeaders)
}
// IsCORSFinding reports whether vulnclass identifies a CORS finding. Finding
// class is the canonical vulnerability type stored on a findings row; task
// categories are not part of this decision.
func IsCORSFinding(vulnClass string) bool {
for _, token := range strings.FieldsFunc(strings.ToLower(strings.TrimSpace(vulnClass)), func(r rune) bool {
return r < 'a' || r > 'z'
}) {
if token == "cors" {
return true
}
}
return false
}
func singleHeaderValue(headers http.Header, name string) (string, error) {
values := headerValues(headers, name)
if len(values) == 0 {
return "", fmt.Errorf("header is missing")
}
if len(values) != 1 {
return "", fmt.Errorf("header has multiple values")
}
return values[0], nil
}
func singleHeaderValueOptional(headers http.Header, name string) (string, error) {
values := headerValues(headers, name)
if len(values) == 0 {
return "", nil
}
if len(values) != 1 {
return "", fmt.Errorf("header has multiple values")
}
return values[0], nil
}
// headerValues performs a case-insensitive lookup even for maps constructed
// directly by callers rather than through Header.Set, while preserving duplicate
// values so malformed CORS responses fail closed.
func headerValues(headers http.Header, name string) []string {
var values []string
for key, current := range headers {
if strings.EqualFold(key, name) {
values = append(values, current...)
}
}
return values
}
// parseStoredHeaders parses the first-line-prefixed raw header format used by
// traffic evidence. MIMEHeader is deliberately used here instead of splitting
// on colons so folded/malformed header lines follow the standard parser.
func parseStoredHeaders(raw string) (http.Header, error) {
raw = strings.ReplaceAll(raw, "\r\n", "\n")
raw = strings.ReplaceAll(raw, "\r", "\n")
lineEnd := strings.IndexByte(raw, '\n')
if lineEnd < 0 {
return nil, fmt.Errorf("missing HTTP start line")
}
headerBlock := strings.ReplaceAll(raw[lineEnd+1:], "\n", "\r\n") + "\r\n"
mime, err := textproto.NewReader(bufio.NewReader(strings.NewReader(headerBlock))).ReadMIMEHeader()
if err != nil {
return nil, err
}
return http.Header(mime), nil
}
-128
View File
@@ -1,128 +0,0 @@
package db
import (
"net/http"
"strings"
"testing"
)
func TestValidateBrowserOrigin(t *testing.T) {
tests := []struct {
name string
origin string
wantOK bool
}{
{name: "https", origin: "https://evil.com", wantOK: true},
{name: "http port", origin: "http://attacker.example:8443", wantOK: true},
{name: "custom scheme", origin: "chrome-extension://abcdefghijklmnop", wantOK: true},
{name: "IPv6", origin: "https://[2001:db8::1]", wantOK: true},
{name: "opaque", origin: "null", wantOK: true},
{name: "missing scheme", origin: "evil.com"},
{name: "trailing slash", origin: "https://evil.com/"},
{name: "empty fragment", origin: "https://evil.com#"},
{name: "path", origin: "https://evil.com/path"},
{name: "query", origin: "https://evil.com?x=1"},
{name: "fragment", origin: "https://evil.com#frag"},
{name: "userinfo", origin: "https://user:pass@evil.com"},
{name: "internal whitespace", origin: "https://target.com\tevil.com"},
{name: "uppercase scheme", origin: "HTTPS://evil.com"},
{name: "uppercase host", origin: "https://EVIL.com"},
{name: "explicit default port", origin: "https://evil.com:443"},
{name: "leading zero port", origin: "https://evil.com:0443"},
{name: "empty port", origin: "https://evil.com:"},
{name: "invalid IPv6 serialization", origin: "https://[2001:0DB8::1]"},
{name: "domain underscore", origin: "https://evil_site.com"},
{name: "unicode host", origin: "https://例え.テスト"},
{name: "javascript", origin: "javascript:alert(1)"},
{name: "empty", origin: ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := ValidateBrowserOrigin(tt.origin)
if tt.wantOK && err != nil {
t.Fatalf("ValidateBrowserOrigin(%q) = %v, want success", tt.origin, err)
}
if !tt.wantOK && err == nil {
t.Fatalf("ValidateBrowserOrigin(%q) succeeded, want error", tt.origin)
}
})
}
}
func TestValidateCORSProof(t *testing.T) {
tests := []struct {
name string
origin string
acao string
acac string
wantOK bool
wantReason string
}{
{name: "wildcard without credentials", origin: "https://evil.com", acao: "*", wantOK: true},
{name: "wildcard credentials", origin: "https://evil.com", acao: "*", acac: "TrUe", wantReason: "wildcard"},
{name: "mismatch", origin: "https://evil.com", acao: "https://other.example", wantReason: "does not match"},
{name: "missing ACAO", origin: "https://evil.com", wantReason: "missing"},
{name: "valid reflection with credentials", origin: "https://evil.com", acao: "https://evil.com", acac: "true", wantOK: true},
{name: "opaque reflection", origin: "null", acao: "null", wantOK: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req := http.Header{}
req.Set("Origin", tt.origin)
resp := http.Header{}
if tt.acao != "" {
resp.Set("Access-Control-Allow-Origin", tt.acao)
}
if tt.acac != "" {
resp.Set("Access-Control-Allow-Credentials", tt.acac)
}
err := ValidateCORSProof(req, resp)
if tt.wantOK && err != nil {
t.Fatalf("ValidateCORSProof() = %v, want success", err)
}
if !tt.wantOK {
if err == nil {
t.Fatal("ValidateCORSProof() succeeded, want error")
}
if !strings.Contains(strings.ToLower(err.Error()), strings.ToLower(tt.wantReason)) {
t.Fatalf("error %q does not contain %q", err, tt.wantReason)
}
}
})
}
}
func TestValidateCORSProofHeads(t *testing.T) {
err := ValidateCORSProofHeads(
"GET / HTTP/1.1\nOrigin: https://evil.com\n",
"HTTP/1.1 200 OK\nAccess-Control-Allow-Origin: https://evil.com\nAccess-Control-Allow-Credentials: true\n",
)
if err != nil {
t.Fatalf("ValidateCORSProofHeads() = %v, want success", err)
}
err = ValidateCORSProofHeads(
"GET / HTTP/1.1\nOrigin: https://evil.com\n",
"HTTP/1.1 200 OK\nAccess-Control-Allow-Origin: https://other.example\n",
)
if err == nil || !strings.Contains(err.Error(), "does not match") {
t.Fatalf("invalid head proof error = %v, want mismatch", err)
}
}
func TestIsCORSFinding(t *testing.T) {
for _, tc := range []struct {
class string
want bool
}{
{class: "CORS", want: true},
{class: "cors misconfiguration", want: true},
{class: "cors_misconfiguration", want: true},
{class: "course injection", want: false},
{class: "XSS", want: false},
} {
if got := IsCORSFinding(tc.class); got != tc.want {
t.Errorf("IsCORSFinding(%q) = %v, want %v", tc.class, got, tc.want)
}
}
}
-44
View File
@@ -1,44 +0,0 @@
package server
import (
"fmt"
"strings"
"testing"
"github.com/Autumn-27/artex/db"
)
func TestCORSVerificationRejectsInvalidBoundProof(t *testing.T) {
s, finding, request := trafficEvidenceServer(t)
if _, err := s.m.pg.Exec(`UPDATE findings SET vulnclass='CORS' WHERE id=$1`, finding.FindingID); err != nil {
t.Fatal(err)
}
trafficID := "cors-invalid-proof"
_, err := s.m.traffic.DB().Exec(`INSERT INTO exchanges(id,ts,host,method,url_template,url,status,content_type,req_len,resp_len,path)
VALUES(?,1,'evidence.local','GET','/','https://evidence.local/',200,'text/plain',0,?,'')`, trafficID, len("cors proof body"))
if err != nil {
t.Fatal(err)
}
_, err = s.m.traffic.DB().Exec(`INSERT INTO exchange_bodies(id,req_head,resp_head,req_body,resp_body)
VALUES(?, ?, ?, ?, ?)`, trafficID,
"GET / HTTP/1.1\nOrigin: https://evil.com\n",
"HTTP/1.1 200 OK\nAccess-Control-Allow-Origin: https://other.example\n",
[]byte{}, []byte("cors proof body"))
if err != nil {
t.Fatal(err)
}
bindPath := fmt.Sprintf("/api/exploration/findings/%d/traffic", finding.FindingID)
if w := request("POST", bindPath, fmt.Sprintf(`{"traffic_refs":[{"traffic_id":%q,"role":"proof"}]}`, trafficID)); w.Code != 200 {
t.Fatalf("bind: %d %s", w.Code, w.Body)
}
msg, isErr := updateReport(t, s, finding.NodeID, `,"poe_level":3,"evidence_quotes":["cors proof body"]`)
if isErr || !strings.Contains(msg, "verification: unverified") {
t.Fatalf("unexpected result: err=%v %q", isErr, msg)
}
status, _, note, report := storedVerification(t, s, finding.FindingID)
if status != db.VerificationUnverified || !strings.Contains(note, "CORS proof validation failed") || report == "" {
t.Fatalf("stored: status=%s note=%q report=%q", status, note, report)
}
}
-14
View File
@@ -138,13 +138,6 @@ func readBoundResponse(store *evidence.Store, snap db.TrafficEvidenceSnapshot) (
// its bound traffic and the quotes the agent supplied. poe is the declared POE
// level (0 when absent). It never returns "verified" unless every rule passes.
func (s *Server) assessFindingVerification(ctx context.Context, findingID int64, poe int, quotes []string) (status, note string) {
finding, err := s.m.pg.GetFinding(findingID)
if err != nil {
return db.VerificationNotAssessed, "finding read error: " + err.Error()
}
if finding == nil {
return db.VerificationNotAssessed, "finding not found"
}
tr, err := s.m.pg.GetFindingTraffic(ctx, findingID)
if err != nil {
return db.VerificationNotAssessed, "binding read error: " + err.Error()
@@ -158,13 +151,6 @@ func (s *Server) assessFindingVerification(ctx context.Context, findingID int64,
if len(proofs) == 0 {
return db.VerificationUnverified, "no proof traffic bound"
}
if db.IsCORSFinding(finding.VulnClass) {
for _, proof := range proofs {
if err := db.ValidateCORSProofHeads(proof.Snapshot.ReqHead, proof.Snapshot.RespHead); err != nil {
return db.VerificationUnverified, "CORS proof validation failed: " + err.Error()
}
}
}
if poe < verificationMinPOE {
return db.VerificationUnverified, fmt.Sprintf("POE L%d below L3", poe)
}