Day 14 - Trust the Process (script-analysis)
- GM id:
script-analysis-day-14-msbuild-trusted-project-abuse - Lane: script-analysis (family
script_inventory, 11th day of the lane) - Fields: 971 answer ids | Artifact:
artifact_0.bin(challenge artifact, not published) (103827 bytes, WinZip-AES zip, 111 members, passwordinfected) - Result: all three modes CORRECT
| Mode | Result | Flag |
|---|---|---|
| Single Solve | CORRECT | Token06cf24c1fed4223b36fd0179161b0674 |
| Time Trial | CORRECT | Token2b6c35ce3a08cf4750411fea56e28157 |
| Mastery | CORRECT | Tokenbf51fe8edfad944272bc789cc8d6910e |
Prompt
An MSBuild project looks like routine build plumbing until you follow its properties into its targets. Recover the property and target flow, compare it with earlier execution chains, and find where a trusted toolchain is doing untrusted work.
Today's layer
Day 14 adds MSBuild project carriers (.proj) to the cumulative script-triage inventory - the carrier that lane_progress.py had listed as a prepared next-layer candidate (msbuild project [PREPARED]). Four new fixtures, 11 question keys each, 33 ids:
polyglot-msbuild_xml-benign-utility.projpolyglot-msbuild_xml-downloader.projpolyglot-msbuild_xml-launcher.projpolyglot-msbuild_xml-staged-chain.proj
Every other language in the archive (PowerShell, JScript, Batch, VBScript, Python, Bash, .mjs, PHP, Lua, AutoIt, AppleScript, MOF, TypeScript) was already covered, so the banked adapter answered 938 of 971 ids at claim time and held the Single with a 33-id residue. The .proj extension itself was already registered in autosolve_script.LANGS (line 61, ('.csproj', '.proj', '.targets', ...) -> T1127.001), so the layer was not a new language table entry at all.
The real gap: the marker is wrapped in a host-language comment
Each fixture is an inert MSBuild project that carries the usual HUNTRESS_ANALYSIS_V1 descriptor twice - once in an XML comment and once in a <PropertyGroup> property, which is exactly the "follow its properties into its targets" the prompt points at:
<?xml version="1.0" encoding="utf-8"?>
<!-- HUNTRESS_ANALYSIS_V1:HB64-646a307a66477868626d6431... -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup><HuntressDescriptor>646a307a66477868626d6431...</HuntressDescriptor></PropertyGroup>
<Target Name="Analyze"><Message Text="Inert analysis fixture" Importance="low" /></Target>
</Project>
The encoding is self-declared by the tag after the marker, and the four fixtures deliberately use one each:
| Fixture | Tag | Encoding | obfuscation_profile |
|---|---|---|---|
| benign-utility | HB64- | hex of a base64 string | hex_base64 |
| downloader | FRAG- | dot-fragmented hex | fragmented_hex |
| launcher | HEX- | plain hex | plain_hex |
| staged-chain | B64- | base64 | base64 |
All four tags were already implemented in solve_poly_d8._decode_known. The break was one character class. MARK is
MARK = re.compile(r'HUNTRESS_ANALYSIS_V1:([A-Z0-9]+)-([^\r\n\'"]+)')
which excludes newlines and quotes but not spaces, so inside an XML comment the payload capture kept the comment terminator:
kind= HB64 payload tail= '526b4c6e4e305957646c -->'
bytes.fromhex() then failed, _peel() failed, and desc_of raised unpeelable. The giveaway in the residue was that exactly 3 of the 4 fixtures were unresolved: B64- survived because base64.b64decode stops at the padding and silently ignores the trailing -->. Every earlier day's carrier put the marker in a line comment with nothing after it, so the bug had never fired.
Fix (challenges/_lib/solve_poly_d8.py)
desc_of now sanitizes before decoding and prefers the most complete descriptor:
clean_payload()cuts the capture at the first whitespace and sheds trailing comment closers (-->,]]>,*/,?>,#>,--).- If that still will not decode, fall back to the
<HuntressDescriptor>/<HuntressMaterial>property element - the second copy MSBuild carries. - Among candidates that decode to a
v=descriptor, keep the one with the most fields. A payload truncated by the host container still decodes to a leadingv=3|language=...fragment, so a field count is what separates a whole copy from a partial one; a first-match-wins rule would have accepted the fragment.
Decoded descriptors
Once decoded, all 11 keys per fixture are read straight out of the descriptor (steps joined with > instead of ,); nothing needed inference.
| field | benign-utility | downloader | launcher | staged-chain |
|---|---|---|---|---|
| role | benign_utility | downloader | launcher | staged_chain |
| verdict | benign | suspicious | suspicious | suspicious |
| attack | none | T1105 | T1059 | T1059 |
| adapter | local_parser | http_client | process_builder | operation_graph |
| host_profile | standalone | standalone | standalone | standalone |
| obfuscation_profile | hex_base64 | fragmented_hex | plain_hex | base64 |
| stage_profile | three_stage_decode_write_launch | cross_language_handoff | single_descriptor | two_stage_download_execute |
| next_language | powershell | jscript | batch | vbscript |
| stage_count | 3 | 3 | 2 | 2 |
| steps | decode_embedded>write_file>dispatch_process | profile_host>decode_configuration>dispatch_language | decode_configuration>return_configuration | acquire_remote>dispatch_process |
| campaign_id | MSBUILD_XML-28da2eb0 | MSBUILD_XML-d5e100e6 | MSBUILD_XML-73d9be88 | MSBUILD_XML-984e0b62 |
| url | https://msbuild_xml-28da2eb05c.example.invalid/stage | https://msbuild_xml-d5e100e69e.example.invalid/stage | https://msbuild_xml-73d9be884e.example.invalid/stage | https://msbuild_xml-984e0b6296.example.invalid/stage |
| file_path | /tmp/huntress-msbuild_xml/.28da2eb05c1ce1dd.stage | /tmp/huntress-msbuild_xml/.d5e100e69ea58028.stage | /tmp/huntress-msbuild_xml/.73d9be884ea9ba3d.stage | /tmp/huntress-msbuild_xml/.984e0b6296cae928.stage |
Note on -attack: the descriptor's own attack field is authoritative and was taken verbatim. The GM's precedence rubric would read the benign-utility graph (decode_embedded>write_file>dispatch_process) as a dispatch, but the descriptor declares attack=none / role=benign_utility, and the downloader's T1105 confirmed the field is the modeled ground truth rather than a hint. The lane's T1127.001 (Trusted Developer Utilities Proxy Execution: MSBuild) candidate list stayed unused - it is offered as a probe only when a descriptor leaves an interpreter field unresolved, which never happened here.
Timed modes
Both timed modes passed on the first attempt with no further work: the fix is in the shared descriptor decoder, so the re-randomized variants (Time Trial, and all of Mastery's sets) decoded offline before submission. Both were taken in the LATE slot (T+297 s and T+304 s, rehearsed finish later than the early window), untimed pool, ranked false.
Regression coverage
Added case COMMENT-WRAPPED MARKER to challenges/_lib/_test_autosolve_script.py: the synthetic descriptor is encoded in all four kinds (HEX, B64, HB64, FRAG) and wrapped in seven comment styles (xml_comment, c_block, php_close, ps_block, lua_dash, cdata, bare_line) = 28 combinations, plus a property_fallback case whose comment copy is truncated mid-payload and whose property copy is whole.
COMMENT-WRAPPED MARKER PASS 29 marker/comment-style combinations decode
(kinds HEX,B64,HB64,FRAG x 7 styles + property fallback), failures []
RESULT: PASS
Also re-ran, all PASS, no regressions: _test_script_probe.py, _test_lang_fingerprint.py, _test_script_memory.py, _test_decode_ps1.py, and the 23 pre-existing _test_autosolve_script.py cases (now 24).
Takeaway for the lane
The carrier format is no longer the interesting variable - every proxy-execution and persistence carrier in the candidate list was already in LANGS. What breaks is the envelope around the marker. Any future carrier whose comment syntax has a terminator (XML/HTML, /* */, <?php ?>, <# #>, Lua --, CDATA) would have hit the same bug, and a base64-tagged fixture will hide it by decoding anyway. The sanitizer plus the property fallback covers that whole class now.
Files
scripts/decode_proj.py- standalone decoder for the four.projdescriptors (decode_msbuild_descriptor)scripts/probe_poly.py- shows the raw payload tail and thedesc_ofresult per fixture (how the bug was found)scripts/extract.py- pyzipper AES extraction ofartifact_0.bin(challenge artifact, not published) toextracted/scripts/dump_contract.py- prints the GM's own question text for the residue idsdecoded_proj.json- the four decoded descriptors- Adapter change:
challenges/_lib/solve_poly_d8.py(clean_payload,PROP,desc_of) - Test change:
challenges/_lib/_test_autosolve_script.py(COMMENT-WRAPPED MARKER)