Repository navigation
config: enforce required fields after parsing (ProtoJSON missing-field crash) - #391
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. |
|
CLA signed (Google Individual CLA, GitHub username newkpl) — rechecking the CLA status. |
|
Hi, gentle ping on this fix. It addresses a ProtoJSON config that omits the required Exe.path field crashing the config parser with a null dereference, instead of the config being rejected for the missing field. The patch is small and self-contained, and I am happy to add a test or adjust the approach if you prefer a different shape. I also noticed the workflow runs on this PR are awaiting approval on your side; just let me know if anything is needed from me. Thanks for your time. |
NsJailConfig's Exe.path is a required proto2 field, but config::parseFile() never checks IsInitialized() on the parsed config, and the ProtoJSON path (util::JsonStringToMessage) — unlike TextFormat — does not enforce required fields.
A ProtoJSON config such as {"execBin": {"arg0": "ARG0ONLY"}} therefore reaches parseInternal() with has_exec_bin=1, has_path=0, arg_size=0, where nsj->argv[0] = njc.exec_bin().arg0() writes into an empty std::vector → deterministic SEGV (null dereference in the libstdc++ string assignment), reproduced 3/3 at HEAD (d1d9af3) with an ASan-instrumented build: SEGV on unknown address 0x000000000000, top frame config::parseInternal ← config::parseFile ← cmdline::parseArgs ← main. Also reproduced in a plain (non-sanitizer) micro-repro of the exact code shape (SIGSEGV, rc=139).
A sibling variant (args present, no path) does not crash but silently overwrites argv[0], and setupArgv() then promotes it to the executed program — wrong-program execution from a malformed config.
Fix:
Verification: with this patch, both JSON attack variants are cleanly rejected ("Config file ... is missing required fields", rc=255, no sanitizer report), and valid TextFormat/ProtoJSON control configs behave unchanged. TextFormat twins of the attack configs were already rejected by the parser, confirming the JSON path was the gap.
Severity is low/hardening: the config file is operator-supplied; impact is a launcher crash or wrong-program execution from a malformed config. No sandbox-boundary, privilege, or jailed-process impact.
Disclosure: this patch was prepared with AI assistance; the crash, the sibling variant, and the fix were all reproduced and verified on local builds before submission.