Skip to content

Commit 18a1035

Browse files
committed
policy: filter_username rejects User-Names containing an xlat opener
Reject the '%{' and '%name(' expansion openers in User-Name so there's no chance of poorly written API code reflecting them back and having nested evaluation occur. This is a belt and braces change, as expansion defaults to disabled in v4 for the rest module, and it's somewhat unlikely that an admin woul insert one of these raw values into an SQL policy. It's probably unecessary but at least it quiets the CVE farmers.
1 parent 7d61b05 commit 18a1035

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

raddb/policy.d/filter

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ filter_username {
3434
}
3535
}
3636
elsif (User-Name) {
37+
#
38+
# Prevention of injection attacks if external datastores or APIs fail to sanitise text
39+
#
40+
# Matches the "%{" and "%name(" xlat expansion openers.
41+
# "%%" is the documented escape sequence for a literal "%".
42+
#
43+
if (User-Name =~ /%%([{]|[[:alnum:]._-]+[(])/) {
44+
request += {
45+
Module-Failure-Message = "User-Name contains expansion sequences"
46+
}
47+
reject
48+
}
49+
3750
#
3851
# reject mixed case e.g. "UseRNaMe"
3952
#

0 commit comments

Comments
 (0)