Skip to content

Commit ab659b5

Browse files
committed
api: validate arg in AbstractQubesAPI.__init__()
Validate arg against qrexec allowed characters, consistent with sanitize_name() in qrexec-daemon.c. This ensures consistent behavior between dom0 and management qube. Related: #751
1 parent 891576d commit ab659b5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

qubes/api/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def __init__(
166166

167167
#: argument
168168
self.arg = arg.decode("ascii")
169+
# Validate arg against qrexec allowed characters
170+
# Consistent with sanitize_name() in qrexec-daemon.c
171+
if self.arg and not re.match(r"\A[\x20-\x7E]+\Z", self.arg):
172+
raise ProtocolError(f"arg not allowed in qrexec: {self.arg!r}")
169173
#: name of the method
170174
self.method = method_name.decode("ascii")
171175

0 commit comments

Comments
 (0)