ADD_ONION command returns 512 Bad arguments when space present in TARGET Port unix path
Summary
Attempting to add a new onion address over Tor's control port via ADD_ONION
with a target port for a unix socket. If the path of that unix socket contains a space, Tor returns 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
The path cannot be quoted like with SET_CONF
or setting the HiddenServicePort
in the config. (eg: unix:"/some/path/with space/hs.sock"
)
What is the current bug behavior?
ADD_ONION
command does not accept unix sockets that contain a space in the path.
What is the expected behavior?
ADD_ONION
should accept quoted path for unix socket as the TARGET port, the same way it does for SET_CONF
and in the tor config file.
Environment
- Which version of Tor are you using? Run
tor --version
to get the version if you are unsure.
Tor 0.4.7.8 (git-7528524aee3ffe3c) running on Linux with Libevent 2.1.12-stable, OpenSSL 1.1.1o, Zlib 1.2.11, Liblzma N/A, Libzstd N/A and Glibc 2.33 as libc.
- Which operating system are you using? For example: Debian GNU/Linux 10.1, Windows 10, Ubuntu Xenial, FreeBSD 12.2, etc.
Pop!_OS 22.04 LTS
- Which installation method did you use? Distribution package (apt, pkg, homebrew), from source tarball, from Git, etc.
Tor binaries are fromtor-browser-build
, running via Jvm using Kotlin Multiplatform Tor
Relevant logs and/or screenshots
Succeeds only when there is no space in the path
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:/tmp/junit7656060516802870873/torservice/data/test_hs.sock
D/<< 250-ServiceID=zahvtr2ytdpcvwqwu5iexxny56bprbc24d54gnfly2mmakszhextcwqd
D/<< 250-PrivateKey=ED25519-V3:EC2Vmd4EDlOtsHIiRjWCJBwzFn8f9vESjICbOvr6sUlPCBAPiWejikz5dQvyqvy4cHml/w6j5d8Xe+UN52YioQ==
D/<< 250 OK
Failure when space present
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:/tmp/junit1395906562298175606/tor service/data/test_hs.sock
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
Does not accept a quoted path like other controller + config declarations do (ex: unix:"/pa th/to/hs.sock"
)
Multiple attempts to quote the path to see what Tor would accept
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:"/tmp/junit11141792629624884881/tor service/data/test_hs.sock"
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,"unix:\"/tmp/junit9907345219862884922/tor service/data/test_hs.sock\""
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:/tmp/junit8276306503427149359/'tor service'/data/test_hs.sock
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:/tmp/junit3639204659535652534/tor\ service/data/test_hs.sock
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port="8764,unix:/tmp/junit10022844120041534159/tor service/data/test_hs.sock"
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port="8764 unix:/tmp/junit5623947952132400600/tor service/data/test_hs.sock"
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port="8764 unix:\"/tmp/junit7600073482601005748/tor service/data/test_hs.sock\""
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port="8764,unix:\"/tmp/junit2071402153395563988/tor service/data/test_hs.sock\""
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:/tmp/junit1872035082845200589/"tor service"/data/test_hs.sock
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:/tmp/junit4651827787803341153/\"tor service\"/data/test_hs.sock
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
D/>> ADD_ONION NEW:ED25519-V3 Flags=MaxStreamsCloseCircuit MaxStreams=4 Port=8764,unix:/tmp/junit14411247957552193815/\'tor service\'/data/test_hs.sock
D/<< 512 Bad arguments to ADD_ONION: Cannot parse keyword argument(s)
Possible fixes
Look for a quoted unix socket path and take argument between quotes