aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/attacksurface.md
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-11 22:13:31 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-12 11:13:35 +0200
commit7fe35e8c15f4c10a5ccaeaa0864ece39469daea6 (patch)
tree72eb403c8d0ef420414e1b55501f0ebcb4afbd22 /attacksurface.md
parentservice: run UI at high integrity (diff)
downloadwireguard-windows-7fe35e8c15f4c10a5ccaeaa0864ece39469daea6.tar.xz
wireguard-windows-7fe35e8c15f4c10a5ccaeaa0864ece39469daea6.zip
service: run UI with elevated token
There are too many attacks possible when starting this with a non-elevated token. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--attacksurface.md10
1 files changed, 4 insertions, 6 deletions
diff --git a/attacksurface.md b/attacksurface.md
index 7eefb677..8010d7b0 100644
--- a/attacksurface.md
+++ b/attacksurface.md
@@ -29,17 +29,15 @@ The manager service is a userspace service running as Local System, responsible
- A writable `CreateFileMapping` handle to a binary ringlog shared by all services, inherited by the unprivileged UI process. It's unclear if this brings with it surprising hidden attack surface in the mm system.
- It listens for service changes in tunnel services according to the string prefix "WireGuardTunnel$".
- It manages DPAPI-encrypted configuration files in Local System's local appdata directory, and makes some effort to enforce good configuration filenames.
- - It uses `wtsEnumerateSessions` and `WTSSESSION_NOTIFICATION` to walk through each available session. It then uses `wtfQueryUserToken`, and then calls `GetTokenInformation(TokenGroups)` on it. If one of the returned group's SIDs matches `CreateWellKnownSid(WinBuiltinAdministratorsSid)`, and has attributes of either `SE_GROUP_ENABLED` or `SE_GROUP_USE_FOR_DENY_ONLY` and calling `GetTokenInformation(TokenElevation)` on it or its `TokenLinkedToken` indicates that either is elevated, then it spawns the unprivileged UI process as that (unelevated) user token, passing it three unnamed pipe handles for IPC and the log mapping handle, as descried above.
+ - It uses `wtsEnumerateSessions` and `WTSSESSION_NOTIFICATION` to walk through each available session. It then uses `wtfQueryUserToken`, and then calls `GetTokenInformation(TokenGroups)` on it. If one of the returned group's SIDs matches `CreateWellKnownSid(WinBuiltinAdministratorsSid)`, and has attributes of either `SE_GROUP_ENABLED` or `SE_GROUP_USE_FOR_DENY_ONLY` and calling `GetTokenInformation(TokenElevation)` on it or its `TokenLinkedToken` indicates that either is elevated, then it spawns the UI process as that the elevated user token, passing it three unnamed pipe handles for IPC and the log mapping handle, as descried above.
### UI
-The UI is an unprivileged process running as the ordinary user for each user who is in the Administrators group (per the above). It exposes:
+The UI is a process running for each user who is in the Administrators group (per the above). It exposes:
- - The manager service (above) calls `GetSecurityInfo(ATTRIBUTE_SECURITY_INFORMATION|LABEL_SECURITY_INFORMATION|SCOPE_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION)` on itself. Then it examines all of the groups associated with the users token, and finds the first one that is of type `SE_GROUP_LOGON_ID`. It adds to the prior DACL one for this SID for only `PROCESS_QUERY_LIMITED_INFORMATION` permission. Then it passes the returned security attributes as the UI's process and thread attributes in the call to `CreateProcessAsUser`. This means that debugging the UI process (in order for another process to steal its handles and exfiltrate private keys) is only possible by processes that can debug the manager service.
- - Right now, we're removing the SACL/integrity level from the above, which means the UI process only requires medium integrity to access it. Requiring greater integrity level access prevents the process from running properly, unfortunately (`ERROR_PRIVILEGE_NOT_HELD`). It would be nice to require high integrity to open the process, without having to increase the privileges that the process has in its own token.
- - Actually, for the time being, we're giving the UI a high integrity token. This is a bummer but seems unavoidable.
- - Perhaps due to the above and other reasons, it appears that it is possible for other processes to write into the UI process's message loop, which is bad, and might defeat the purpose of the above. On the other hand, the permissions of the above are fairly strict (`O:BAG:SYD:(A;;0x1fffff;;;SY)(A;;0x121411;;;BA)(A;;0x1000;;;S-logonsid)`).
+ - Since the UI process is executed with an elevated token, it runs at high integrity and should be immune to various shatter attacks, modulo the great variety of clever bypasses in the latest Windows release.
- It renders highlighted config files to a msftedit.dll control, which typically is capable of all sorts of OLE and RTF nastiness that we make some attempt to avoid.
+ - The syntax editor invokes `IID_ITextDocument` with `QueryInterface`, which might undermine the high integrity token.
### Updates