Skip to content

[kani] Prove bounded UTF-8 validation - #3654

Open
joshlf wants to merge 1 commit into
Gyiyzmayequ5ugyjdxzkhyjwnp6pggabjfrom
Gti2px6v6qyolz34c5rkfkgsrcirhtxpe
Open

[kani] Prove bounded UTF-8 validation#3654
joshlf wants to merge 1 commit into
Gyiyzmayequ5ugyjdxzkhyjwnp6pggabjfrom
Gti2px6v6qyolz34c5rkfkgsrcirhtxpe

Conversation

@joshlf

@joshlf joshlf commented Sep 7, 2026

Copy link
Copy Markdown
Member

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.


Latest Update: v50 — Compare vs v49

📚 Full Patch History

Links show the diff between the row version and the column version.

Version v49 v48 v47 v46 v45 v44 v43 v42 v41 v40 v39 v38 v37 v36 v35 v34 v33 v32 v31 v30 v29 v28 v27 v26 v25 v24 v23 v22 v21 v20 v19 v18 v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v50 v49 v48 v47 v46 v45 v44 v43 v42 v41 v40 v39 v38 v37 v36 v35 v34 v33 v32 v31 v30 v29 v28 v27 v26 v25 v24 v23 v22 v21 v20 v19 v18 v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v49 v48 Base
v48 v47 Base
v47 v46 Base
v46 v45 Base
v45 v44 Base
v44 v43 Base
v43 v42 Base
v42 v41 Base
v41 v40 Base
v40 v39 Base
v39 v38 Base
v38 v37 Base
v37 v36 Base
v36 v35 Base
v35 v34 Base
v34 v33 Base
v33 v32 Base
v32 v31 Base
v31 v30 Base
v30 v29 Base
v29 v28 Base
v28 v27 Base
v27 v26 Base
v26 v25 Base
v25 v24 Base
v24 v23 Base
v23 v22 Base
v22 v21 Base
v21 v20 Base
v20 v19 Base
v19 v18 Base
v18 v17 Base
v17 v16 Base
v16 v15 Base
v15 v14 Base
v14 v13 Base
v13 v12 Base
v12 v11 Base
v11 v10 Base
v10 v9 Base
v9 v8 Base
v8 v7 Base
v7 v6 Base
v6 v5 Base
v5 v4 Base
v4 v3 Base
v3 v2 Base
v2 v1 Base
v1 Base
⬇️ Download this PR

Branch

git fetch origin refs/heads/Gti2px6v6qyolz34c5rkfkgsrcirhtxpe && git checkout -b pr-Gti2px6v6qyolz34c5rkfkgsrcirhtxpe FETCH_HEAD

Checkout

git fetch origin refs/heads/Gti2px6v6qyolz34c5rkfkgsrcirhtxpe && git checkout FETCH_HEAD

Cherry Pick

git fetch origin refs/heads/Gti2px6v6qyolz34c5rkfkgsrcirhtxpe && git cherry-pick FETCH_HEAD

Pull

git pull origin refs/heads/Gti2px6v6qyolz34c5rkfkgsrcirhtxpe

Stacked PRs enabled by GHerrit.

@google-cla

google-cla Bot commented Sep 7, 2026

Copy link
Copy Markdown

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T05:40:43.662229Z 727f9f8 Manual request
🔒 Security Review Completed 2026-09-08T21:36:07.050627Z 0d929cf Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov-commenter

codecov-commenter commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.85%. Comparing base (6fe1450) to head (727f9f8).

Additional details and impacted files
@@                        Coverage Diff                         @@
##           Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj    #3654   +/-   ##
==================================================================
  Coverage                              91.85%   91.85%           
==================================================================
  Files                                     20       20           
  Lines                                   6093     6093           
==================================================================
  Hits                                    5597     5597           
  Misses                                   496      496           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from bd1ccdb to 5bdc725 Compare September 7, 2026 17:14
@joshlf
joshlf force-pushed the Gti2px6v6qyolz34c5rkfkgsrcirhtxpe branch 2 times, most recently from 17ccb01 to e985ff7 Compare September 7, 2026 17:47
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from 5bdc725 to a802f42 Compare September 7, 2026 17:47
@joshlf
joshlf force-pushed the Gti2px6v6qyolz34c5rkfkgsrcirhtxpe branch from e985ff7 to 5a84428 Compare September 7, 2026 18:13
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from a802f42 to 170146b Compare September 7, 2026 18:13
@joshlf

joshlf commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 5a8442871d567d44cf7da354ff1a9ecff3509f41; in particular, challenge the documented proof domain and exclusions, and verify that expected behavior comes from an independent safe Rust, standard-library, language, or explicitly labeled policy oracle.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a8442871d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread zerocopy/src/impls.rs Outdated
Comment on lines +1629 to +1630
// Excludes: Empty and longer strings, properties outside Kani's model, and
// an independent proof of UTF-8 validity itself.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include the empty string in the bounded proof

BLOCKING: For &[], the empty string is valid UTF-8 and exercises the zero-length slice/DST boundary, but every harness starts at N = 1 and this line explicitly excludes that case. Consequently, the bounded result does not cover every length through four and leaves the pointer metadata and public conversion behavior at the lower boundary unverified. Add a dedicated N = 0 harness that calls check_str_try_ref_from_bytes([]) without the invalid-input coverage assertion.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in the current revision. A dedicated zero-length harness now checks [] against core::str::from_utf8 and exercises the public borrowed conversion without requiring an impossible invalid-input cover. The family domain is now lengths 0 through 4.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 5a8442871d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@joshlf
joshlf force-pushed the Gti2px6v6qyolz34c5rkfkgsrcirhtxpe branch from 5a84428 to 658451e Compare September 7, 2026 19:04
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from 170146b to 017f40b Compare September 7, 2026 19:04
@joshlf

joshlf commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 658451eef013312992be018802c5a1bab137c8b5; in particular, challenge the documented proof domain and exclusions, and verify that expected behavior comes from an independent safe Rust, standard-library, language, or explicitly labeled policy oracle.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 658451eef0

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 658451eef0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread zerocopy/src/impls.rs Outdated
Comment on lines +1665 to +1667
// Oracle: `core::str::from_utf8` is the authoritative safe Rust oracle.
// Consequently, these harnesses prove zerocopy's validator/cast plumbing,
// not the standard library's UTF-8 algorithm.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Supply a versioned normative basis for the UTF-8 oracle

BLOCKING: core::str::from_utf8 is also the operation used by the TryFromBytes for str implementation at lines 175–178, so it is independent for checking the surrounding cast/API plumbing but not for independently checking the validator's UTF-8 decision. This paragraph should cite the versioned standard-library contract and explicitly delimit that dependency, or use a genuinely independent UTF-8 oracle; otherwise the documented claim that the validator agrees with an independent oracle is unsupported.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

Comment thread zerocopy/src/impls.rs Outdated
Comment on lines +1669 to +1673
// Excludes: Longer strings, properties outside Kani's model, an independent
// proof of UTF-8 validity itself, and the public borrowed API's
// invalid-input path. The latter is not invoked because a bug which
// materialized invalid `str` would be undefined before its `Result` could
// safely be inspected, and Kani does not completely check invalid values.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Enumerate the concrete and model-specific proof bounds

BLOCKING: The generic exclusion of “properties outside Kani's model” omits the concrete loop/allocation bounds and the harnesses' #[kani::unwind(5)] limit, and it does not explicitly identify Kani's incomplete reference-aliasing, pointer-provenance, or uninitialized-memory checking. The provenance limitation is especially material because this family claims input-address retention; document these bounds and non-goals explicitly so the stated proof domain is not broader than the verifier's coverage.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in the current revision. The UTF-8 family now records fixed stack inputs of lengths 0..=4, no allocation, no kani::assume, no explicit proof loop, and #[kani::unwind(5)]. It also limits pointer equality to an address observation in Kani’s model and explicitly leaves aliasing, provenance, invalid-value, and uninitialized-memory obligations in the tool/TCB boundary.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 4caa07fe03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from 7930a08 to e2010a6 Compare September 9, 2026 00:45
@joshlf
joshlf force-pushed the Gti2px6v6qyolz34c5rkfkgsrcirhtxpe branch from 4caa07f to eec7b6f Compare September 9, 2026 00:45
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from e2010a6 to 7930a08 Compare September 9, 2026 00:48
@joshlf
joshlf force-pushed the Gti2px6v6qyolz34c5rkfkgsrcirhtxpe branch from eec7b6f to 4caa07f Compare September 9, 2026 00:48
@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 4caa07fe03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from 7930a08 to d72291e Compare September 9, 2026 01:35
@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 35cb45d8816c29b74d9a3cd2ad06e7e756444496; in particular, challenge the documented proof domain and exclusions, and verify that expected behavior comes from an independent safe Rust, standard-library, language, or explicitly labeled policy oracle.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35cb45d881

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread zerocopy/src/impls.rs Outdated
// https://doc.rust-lang.org/1.93.0/reference/type-layout.html#the-transparent-representation

fn utf8_oracle(bytes: &[u8]) -> (Result<&str, core::str::Utf8Error>, bool) {
let expected = core::str::from_utf8(bytes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace the self-referential UTF-8 oracle

BLOCKING: Fresh evidence after the earlier thread was marked addressed is that current head 35cb45d again defines the oracle with core::str::from_utf8, while the TryFromBytes for str implementation under proof calls that same function at line 178. Thus the validator harness can check the surrounding pointer/cast plumbing, but its expected validity classification is not independent and cannot substantiate the documented validator-equivalence proof under the repository's oracle rules. Restore an independent safe Rust or language-derived UTF-8 classifier (or an explicitly labeled policy oracle), or drop the validator-equivalence claim.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed. The oracle no longer calls core::str::from_utf8; it is an independent bounded classifier over Unicode 17 Table 3-7's nine well-formed UTF-8 sequence rows. The proof labels the Rust-to-Unicode bridge and manual table transcription as EXTERNAL-SPEC/TCB, documents the loop invariant, and keeps the claim limited to lengths 0 through 4.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 15c2f1a3c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review exact head 2dd56322841c95b9693d220a74773b4cc7c320b5.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 2dd5632284

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@codex review

Exact-head review request: 707b51d

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 707b51da15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

*Authored by an AI agent acting on Josh Liebow-Feeser's behalf.*

gherrit-pr-id: Gti2px6v6qyolz34c5rkfkgsrcirhtxpe
@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@codex review

Exact-head review request: 727f9f8

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 727f9f8719

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread zerocopy/src/impls.rs
Comment on lines +1995 to +1996
let expected_valid = utf8_oracle(&bytes);
assert_same_bool(expected_valid, true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add cover obligations to the empty harnesses

BLOCKING: When either zero-length proof is selected by itself through ci/run_kani.sh, it emits no cover summary, so the wrapper's fail-closed check_cover_summaries rejects the otherwise successful run with “Kani emitted no recognized cover summary.” This makes both prove_empty_str_validators and prove_empty_str_try_ref_from_bytes unusable as independently selected harnesses; add a reachable valid-partition cover such as kani::cover!(expected_valid, "empty input is accepted") to each.

AGENTS.md reference: AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants