Hi, @fzipi, i hope you doing well, i'm RelunSec from InsiteTech.jp
we discovered a parser confusion in cookie parser, i used a simple flask app that print the cookies
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def index():
# 1. Print all cookies as a dictionary to your terminal console
print("All cookies:", request.cookies)
return "Cookies logged in terminal!"
if __name__ == '__main__':
app.run(debug=True)
and a go setup
package cookies
import (
"fmt"
"testing"
)
func TestParseCookie(t *testing.T) {
inputs := []string{
"a\v=\t'",
}
fmt.Println("\n==========================================")
fmt.Println(" COOKIE PARSE DIRECT LOCAL RUN ")
fmt.Println("==========================================")
for _, input := range inputs {
// Calling the exact lowercase function name from the repo
cookies := ParseCookies(input)
fmt.Printf("-> Input: %q\n", input)
fmt.Printf(" Output: %q\n", cookies)
fmt.Println("------------------------------------------")
}
fmt.Println("==========================================")
}
i runned the go program as you can see
relunsec@relunsec:~/software/coraza/internal/cookies$ go test
==========================================
COOKIE PARSE DIRECT LOCAL RUN
==========================================
-> Input: "a\v=\t'"
Output: map["a\v":["\t'"]]
------------------------------------------
==========================================
PASS
ok github.com/corazawaf/coraza/v3/internal/cookies 0.003s
and then i sended a curl request to the python flask web app
relunsec@relunsec:~/software/coraza/internal/cookies$ curl 127.0.0.1:5000 -H $'Cookie: a\v=\t'
Cookies logged in terminal!
and then i saw in the running flask app terminal
All cookies: ImmutableMultiDict([('a', "'")])
as you can see python see that as the a cookie and the value of it is ', while coraza see it in a different name and a value
an attacker can craft a crafted payload that evade cookie inspection and then perfom their attack