Skip to content

Reject malformed ORC timezone data and unsafe metadata paths - #35

Merged
skuznetsov-clickhouse merged 5 commits into
ClickHouse/2.3.1from
codex/orc-timezone-validation
Oct 19, 2026
Merged

skuznetsov-clickhouse merged 5 commits into
ClickHouse/2.3.1from
codex/orc-timezone-validation

Conversation

@skuznetsov-clickhouse

@skuznetsov-clickhouse skuznetsov-clickhouse commented Oct 13, 2026 •

Copy link
Copy Markdown

What changes were proposed in this pull request?

Validate timezone data before indexing an empty byte vector, reading a zero-byte TZDB file, using a TZif header with no local-time types, scanning past the counted designation bytes, or constructing a string from a truncated TZif v2 footer. Invalid inputs raise TimezoneError. Reject unsafe serialized timezone-name syntax before joining it to TZDIR, including traversal, absolute and drive-like names, empty components, trailing dots or spaces, and Windows device names. Keep lookup lazy for ORC reads that do not use timezone data. Enable the standard build/test workflow for PRs targeting ClickHouse/2.3.1.

Why are the changes needed?

On the unpatched vendor base, controlled test inputs reproduced separate SIGABRTs for an empty timezone buffer and a zero-byte TZDB file; a zero-type TZif also aborted, an unterminated designation caused an ASan overflow, and a relative name loaded a controlled TZif outside TZDIR. A valid two-section TZif v2 with a 0- or 1-byte footer threw std::length_error instead of a timezone parse error. The guards cover these parser invariants. These local reproducers do not establish the exact failure in Anthropic's private binary.

How was this patch tested?

The crash reproducers ran only on an isolated Linux devserver and are not part of CI. Committed regression tests expect TimezoneError for invalid inputs and cover valid IANA names, aliases, the final-byte NUL boundary, the valid two-newline TZif v2 footer, lazy writer behavior, and Windows reserved-device spellings. On the final files, Debug orc-test passed full CTest (1/1), and an explicitly instrumented ASan/UBSan TestTimezone.* run passed 17/17 enabled tests. git diff --check passed.

Windows CI, downstream ClickHouse integration, and the customer package remain unverified. The existing sanitizer CMake options do not propagate instrumentation flags, so the local sanitizer build used explicit flags. The name check is lexical: a pre-existing symlink in an untrusted TZDIR can still resolve outside that directory.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Codex (GPT-6 Luna Max and GPT-6, 2026-10-13).

Empty timezone buffers and files, zero-type TZif headers, and unterminated designations could reach unchecked accesses. Unsafe serialized timezone names could escape the configured TZDIR. Validate counted input and lexical path syntax before access while keeping lazy resolution for integer-only readers. Add focused regressions and enable PR tests for the ClickHouse ORC vendor branch.

Verification: isolated Linux Debug orc-test CTest 1/1 and explicitly instrumented strict ASan/UBSan TestTimezone 16/16 on these exact source blobs; git diff --check passed. GitHub CI, Windows, ClickHouse integration, and downstream packages remain unverified.
Windows reserves CONIN$ and CONOUT$ in addition to CON, PRN, AUX, NUL and COM/LPT names. Reject these spellings before opening timezone files, and cover case, extension and nested components in the Windows-only test.

Verification: exact-file Linux Debug orc-test CTest 1/1 and strict ASan/UBSan TestTimezone suite 16/16 passed on isolated Chaos Lab. Windows CI remains pending.
The cpp-linter job rejected layout in the timezone guard and regression test. Reflow only those expressions to the repository format; parser behavior is unchanged. clang-format 21 dry-run on the reported ranges and git diff --check pass. CI clang-format 16 and platform tests remain pending.
A zero- or one-byte v2 footer underflows the string length and surfaces std::length_error instead of a timezone parse error. Reject it before constructing the string, while accepting the valid two-newline empty footer.

Verified: isolated Debug CTest 1/1 and explicit ASan/UBSan TestTimezone.* 17/17 on Ubuntu GCC 15.2. Windows CI and customer package remain unverified.
Comment thread .github/workflows/build_and_test.yml Resolved
Comment thread c++/test/TestTimezone.cc Resolved

@thevar1able thevar1able left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks ok.

The build workflow tested pull requests to ClickHouse/2.3.1 but omitted that branch from its push filter, so a merged timezone fix would not receive post-merge CI. Add the branch to push.branches. Verified the staged diff is a single workflow line and passes git diff --check. The post-merge run remains to be observed.
@skuznetsov-clickhouse
skuznetsov-clickhouse merged commit f3e6779 into ClickHouse/2.3.1 Oct 19, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants