mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-01 18:18:31 +00:00
Prevent "regex injection"
If an attacker is able to authenticate with a user name like .* he can bypass limitations imposed by "owner_write" and "owner_only".
This commit is contained in:
parent
c7fe4777b1
commit
4bfe7c9f79
1 changed files with 4 additions and 1 deletions
|
@ -65,7 +65,10 @@ def _read_from_sections(user, collection_url, permission):
|
||||||
"""Get regex sections."""
|
"""Get regex sections."""
|
||||||
filename = os.path.expanduser(config.get("rights", "file"))
|
filename = os.path.expanduser(config.get("rights", "file"))
|
||||||
rights_type = config.get("rights", "type").lower()
|
rights_type = config.get("rights", "type").lower()
|
||||||
regex = ConfigParser({"login": user, "path": collection_url})
|
# Prevent "regex injection"
|
||||||
|
user_escaped = re.escape(user)
|
||||||
|
collection_url_escaped = re.escape(collection_url)
|
||||||
|
regex = ConfigParser({"login": user_escaped, "path": collection_url_escaped})
|
||||||
if rights_type in DEFINED_RIGHTS:
|
if rights_type in DEFINED_RIGHTS:
|
||||||
log.LOGGER.debug("Rights type '%s'" % rights_type)
|
log.LOGGER.debug("Rights type '%s'" % rights_type)
|
||||||
regex.readfp(StringIO(DEFINED_RIGHTS[rights_type]))
|
regex.readfp(StringIO(DEFINED_RIGHTS[rights_type]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue