-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## ROTATE is whatever the standard user said it was\n\nThe Skylight Workspace Config Service runs as `NT AUTHORITY\\SYSTEM`. Its working directory is `C:\\ProgramData\\Amazon\\Skylight Metrics Agent\\`. The parent `C:\\ProgramData\\Amazon\\` inherits the default `ProgramData` ACL, which grants `BUILTIN\\Users` the `(OI)(CI)(special access:)` entry that resolves to create-files, create-directories, and read-and-execute on every child. The Skylight installer does not lock the working directory down further with `SECURITY_ATTRIBUTES` at create time, and the inherited grant carries through.\n\nThe PoC's setup logic confirms what the ACL implies. From `poc.c`:\n\n```c\nDWORD rotateAttrs = GetFileAttributesW(L\"C:\\\\ProgramData\\\\Amazon\\\\Skylight Metrics Agent\\\\ROTATE\");\nif (rotateAttrs == INVALID_FILE_ATTRIBUTES) {\n // create as a junction via mklink /J\n} else if (rotateAttrs & FILE_ATTRIBUTE_REPARSE_POINT) {\n // already a junction, reuse it\n} else {\n // ROTATE exists as a normal directory; delete and recreate as a junction\n if (RemoveDirectoryW(L\"...\\\\ROTATE\") || DeleteFileW(L\"...\\\\ROTATE\")) { ... }\n}\n```\n\nThree branches, one for every initial state the standard user might encounter on a live WorkSpaces instance. If Skylight has not yet created `ROTATE`, the user creates it. If it already exists as a normal directory, the user deletes it and recreates it. If a previous PoC run left a junction in place, the user reuses it. Each branch ends with `ROTATE` as an NTFS junction pointing wherever the standard user chose. The default target in `poc.c` is `C:\\Program Files\\Amazon\\EC2Launch`, the AWS-provided agent that runs at instance boot and loads its plugin DLLs from its own install directory.\n\nThe user then drops a payload into the working directory:\n\n```bat\ncopy AutoPilot.dll \"C:\\ProgramData\\Amazon\\Skylight Metrics Agent\\\"\n```\n\nSkylight's archive routine, named `ArchiveLogFilesExceptFor(currentLog)` in the PoC's reverse-engineering notes, is .NET. The relevant call is `File.Move`:\n\n```csharp\nforeach (var file in Directory.GetFiles(currentDir))\n{\n if (file == currentLog) continue;\n File.Move(file, Path.Combine(rotateDir, Path.GetFileName(file)));\n}\n```\n\n`rotateDir` is the literal string `\"C:\\ProgramData\\Amazon\\Skylight Metrics Agent\\ROTATE\"`. The service does not check the path for the `FILE_ATTRIBUTE_REPARSE_POINT` bit. It does not open the destination with `FILE_FLAG_OPEN_REPARSE_POINT` and reject the open if the attribute is set. It hands a string to `File.Move` and lets the NTFS driver walk the reparse point. When the rotation fires, `File.Move(\".\\\\Skylight Metrics Agent\\\\AutoPilot.dll\", \".\\\\ROTATE\\\\AutoPilot.dll\")` resolves to `C:\\Program Files\\Amazon\\EC2Launch\\AutoPilot.dll`. SYSTEM writes. The ACL on the resulting file is the EC2Launch directory's ACL. The standard user cannot write to `C:\\Program Files\\Amazon\\EC2Launch`. SYSTEM just did, on the standard user's behalf, to a file name the standard user picked, with bytes the standard user supplied.\n\nEC2Launch loads DLLs from its install directory at instance start, with `LoadLibrary` calls on names that resolve before any signature check the WorkSpaces image applies. On the next reboot, `AutoPilot.dll` runs as SYSTEM inside the EC2Launch process. The local privilege escalation primitive is complete on a single reboot, and the persistence is whatever lifetime EC2Launch has. The persistence path is also why the PoC's default target is the EC2Launch directory rather than `System32`. The latter would require a more specific filename matching a DLL EC2Launch's loader resolves; the former takes anything the attacker names AutoPilot.\n\n## The TOCTOU is downstream of the bug\n\nThe CVE record names two issues: TOCTOU and arbitrary file write. The previous section is the arbitrary file write. The TOCTOU is a one-to-ten-millisecond window between `File.Move` completing and Skylight's next call running. That next call, in the PoC's notes, is:\n\n```csharp\npublic static string[] GetArchivedFiles()\n{\n if (!Directory.Exists(rotateDir)) return new string[0];\n return Directory.GetFiles(rotateDir);\n}\n```\n\nThe caller of `GetArchivedFiles` iterates the returned filenames and moves them again, this time to a sibling directory the PoC's notes call `TRANSMITTED`. The second move would resolve through the same junction. The attacker's `AutoPilot.dll`, freshly written to `C:\\Program Files\\Amazon\\EC2Launch\\`, would be picked up by the enumeration, taken back out of `EC2Launch`, and dropped into `C:\\ProgramData\\Amazon\\Skylight Metrics Agent\\TRANSMITTED\\`. The arbitrary file write would have been undone, in milliseconds, by the same loop that wrote it.\n\nThe attacker's job in the TOCTOU window is to delete `ROTATE` between `File.Move` and the `Directory.Exists` check. With the junction gone, `Directory.Exists` returns false. `GetArchivedFiles` returns the empty array. The cleanup move never runs. The file stays at `EC2Launch`.\n\nThe PoC handles the deletion with four monitor threads, `HIGH_PRIORITY_CLASS` on the process, `THREAD_PRIORITY_HIGH` on the watchers, three `ReadDirectoryChangesW` notifiers, and a one-millisecond polling fallback:\n\n```c\nvolatile LONG g_rotateDeleted = 0;\n\nbool DeleteRotateJunction(void) {\n if (InterlockedCompareExchange(&g_rotateDeleted, 1, 0) != 0) return false;\n for (int attempt = 0; attempt < 3; attempt++) {\n if (RemoveDirectoryW(ROTATE_DIR)) {\n if (GetFileAttributesW(ROTATE_DIR) == INVALID_FILE_ATTRIBUTES) return true;\n }\n }\n // fall back to DeleteFileW, then cmd.exe /c rmdir /Q /S as last resort\n}\n```\n\nThe watchers trigger the deletion when the target file appears in `EC2Launch`, when the source file disappears from `Skylight Metrics Agent\\`, or when one-millisecond polling notices either before the directory-change notification arrives. The architecture suggests a race the attacker can lose. The architecture is more than the bug requires; the attacker can lose the cleanup race and re-run at the next rotation tick, and the primitive on the rotation tick after that is what it is.\n\nA TOCTOU mitigation here, adding a stat check between the move and the enumeration, replacing `Directory.Exists` with a handle held across both calls, treating the cleanup as a transactional move, closes the cleanup race. None of them closes the bug. The bug is that the destination of `File.Move` is a path the standard user owns. The race the PoC describes in detail is the race for the cleanup, not the race for the primitive.\n\nThis is the canonical [TOCTOU That Isn't](/patterns/toctou-that-isnt) wedge: the timing word in the CVE title points the fix toward atomicity. The atomicity fix preserves the primitive.\n\n## Why does this exist\n\nThis is [Junction Preemption](/patterns/junction-preemption). Skylight writes to `C:\\ProgramData\\Amazon\\Skylight Metrics Agent\\ROTATE` as SYSTEM and treats the path as if its installer owned it. The installer did not. The parent's ACL says so, and the PoC's setup branch tests every initial state and handles all of them.\n\nThe prior exhibit on this pattern is [Lenovo's LdeApi.Server.exe](/posts/lenovo-lde-junction-preemption), published in April. LdeApi.Server.exe writes `MP27AM7W_estimation.json` to `C:\\ProgramData\\Lenovo\\LDE\\SYSTEM` as SYSTEM. The path does not exist on a fresh install. The PoC pre-creates it as an NTFS mount point into the NT object namespace before the service arrives, then plants a symbolic link inside it pointing to the attacker's chosen target. The service writes through the redirection. Skylight is the same shape, on a different vendor's image, with a cleanup loop the attacker has to step around to make the artifact persist past the next rotation tick. Six weeks between exhibits, two vendors, one pattern.\n\nThe shape is portable because the convention that produces it is portable. `ProgramData` is the documented location for shared application state on Windows. The default ACL on `ProgramData` allows `BUILTIN\\Users` to create subdirectories and files. Microsoft documents both halves of the contract: shared application state goes here, and any service that uses the location must lock down its own subtree on creation with explicit `SECURITY_ATTRIBUTES`. Vendors implement the first half. The second half is the bug.\n\nThe reason the second half stays unimplemented is structural. Subtree ACL lockdown is an install-time decision, and installers are written by a different team than the runtime services that later read and write the paths. The installer ships the directory creation. The service ships the directory use. Nobody owns the ACL on the directory at the moment the service first writes through it. The default inherits. The default is `Authenticated Users`. The bug is shipped.\n\nAmazon WorkSpaces is sold as a managed Windows desktop. The pitch is that AWS handles the image: provisioning, patching, the baseline service set. The standard user is the persona AWS hands the desktop to. The standard user owns `ROTATE`.\n\nThe patch in Skylight 2.6.2034.0, listed in [AWS Security Bulletin 2026-025-AWS](https://aws.amazon.com/security/security-bulletins/), is the right shape for this class. The bulletin does not enumerate the change at source granularity, but the only fixes that close the primitive pre-create `ROTATE` at install time with an ACL that denies non-admin write, or open `ROTATE` with `FILE_FLAG_OPEN_REPARSE_POINT` and reject reparse-point destinations, or resolve the path to a handle once at service start and use the handle for every subsequent move. A pure TOCTOU fix, the one the CVE title invites the reader to imagine, would have closed the cleanup race and left the primitive intact. The CVE record's vocabulary is doing work the patch should not have to.\n\nPoC: [BenZamir/CVE-2026-7791](https://github.com/BenZamir/CVE-2026-7791)","closing_line":"AWS sold a managed Windows desktop. The standard user on it decides where one of its SYSTEM services writes.","hook_md":"Amazon WorkSpaces ships a service called Skylight. It runs as `NT AUTHORITY\\SYSTEM` on every managed Windows desktop AWS sells, and on a schedule it performs log rotation: take the files in `C:\\ProgramData\\Amazon\\Skylight Metrics Agent\\`, move them into a subdirectory called `ROTATE`, enumerate `ROTATE`, hand the contents to the upload path. Skylight does not create `ROTATE`. The standard user does.","post_id":513,"slug":"amazon-workspaces-cve-2026-7791-skylight-doesnt-create-rotate","title":"CVE-2026-7791: Skylight Doesn't Create ROTATE. The Standard User Does.","type":"initial","unreadable_sentence":"The race the PoC describes in detail is the race for the cleanup, not the race for the primitive."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaoiEaQAKCRDeZjl4jgkQ JmlgAQD6YGkYXSQcyEwv+VTwaQTwNyT4KWh93ZKfny+eeGmBzQEA+q40OTZlp2UN iI8Qq0VhzJVOJuilsljuliwNbYzq7wY= =KfLw -----END PGP SIGNATURE-----