GetLAPSPassword: fix LAPS v2 password JSON parse#41
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The decrypted LAPS v2 blob is UTF-16LE JSON. The parse path scanned the raw UTF-16LE bytes backwards for '}' (0x7D) and truncated there, but '}' encodes as 7D 00 - so it kept the low byte and dropped the high 00. utf16ToString then discarded the orphaned byte, deleting the closing brace and failing every parse. Decode the full UTF-16LE plaintext (utf16ToString already stops at the first NUL) and parse with a streaming json.Decoder so trailing metadata after the object is ignored. Add a regression test for the brace-splitting and trailing-metadata cases. Verified end-to-end against a live Windows LAPS v2 (encrypted) host.
psycep
force-pushed
the
fix-lapsv2-json-parse
branch
from
July 17, 2026 03:29
35cf4d3 to
e93d2a4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up from testing #37. Once LAPS v2 decryption worked end-to-end, the tool still failed to parse the recovered password with
failed to parse decrypted JSON, leaving the password unusable in the output.Root cause. The decrypted LAPS v2 blob is UTF-16LE JSON. The parse path scanned the raw UTF-16LE bytes backwards for
}(0x7D) and truncated there — but}encodes as the two bytes7D 00, so it kept the low byte and dropped the high00.utf16ToStringthen couldn't pair the orphaned byte and discarded it, silently deleting the closing brace and breaking every parse.Fix. Decode the full UTF-16LE plaintext (
utf16ToStringalready stops at the first NUL, so NUL-terminated trailing metadata is dropped) and parse with a streamingjson.Decoder, which reads exactly one object and ignores any trailing metadata that isn't NUL-delimited. Removes the byte-level brace scan entirely.Test. Adds a regression test covering the brace-splitting case plus NUL-terminated, trailing-metadata, and password-containing-
}variants.Validation. Verified end-to-end against a live Windows LAPS v2 (encrypted / MS-GKDI) host — the tool now prints the LAPS username and password cleanly where it previously errored.