1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! Kani proof harnesses for `secure_boundary`.
//!
//! Compiled only under `cargo kani` via `#![cfg(kani)]`. See
//! `docs/dev-guide/formal-verification.md` for the proof catalogue and
//! the advisory CI lane (`.github/workflows/kani.yml`).
//!
//! M2 proofs (this file): the request-limit invariants — for any
//! `RequestLimits` configuration, requests that exceed the configured
//! `max_nesting_depth`, `max_field_count`, or `max_body_bytes` are
//! rejected at the structural-validation boundary, never silently
//! accepted.
use crateRequestLimits;
/// Proof: a depth value above the configured `max_nesting_depth` is
/// rejected by the structural-comparison invariant.
///
/// Models the comparison the `SecureJson` extractor performs after
/// parsing — `actual_depth > limits.max_nesting_depth` triggers the
/// reject branch. Kani synthesises symbolic values for the limit and
/// the actual depth, then asserts the discriminant of the comparison.
///
/// Bounds (per the research synthesis):
/// - configured limit ∈ [1, 16]
/// - actual depth ∈ [0, 32]
///
/// Outside these bounds the proof would explode the state space without
/// covering additional cases — every higher value follows by
/// monotonicity of the `>` comparison.
/// Proof: a field count above the configured `max_field_count` is
/// rejected by the structural-comparison invariant.
/// Proof: a body size above the configured `max_body_bytes` is
/// rejected by the structural-comparison invariant.
/// Proof: `RequestLimits::default()` is non-zero on every dimension —
/// catches a future copy-paste accident that initialises a limit to
/// zero (which would silently reject every request).