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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//! SOLVE v0.5 — Scoring Obstacle Levels in Vulnerabilities & Exploits.
//!
//! Scores how hard a vulnerability-discovery and exploit-development challenge is, before
//! anyone attempts it. Four components are judged independently on `0.0..=10.0` and combined
//! with a soft maximum, so a challenge is hard when any single stage is hard, and several hard
//! stages together add at most one further point.
//!
//! ```
//! use solve::{
//! Assessment, CodeAnalysis, CodeLength, Cwe, ExpertKnowledge, ExploitDevelopment, Score,
//! VulnerabilityDiscovery, anchors::{AttackSurface, Locality, Readability},
//! };
//!
//! let assessment = Assessment {
//! code_analysis: CodeAnalysis {
//! readability: Readability::CompiledLogic.score(),
//! complexity: Score::lit(4.0),
//! length: CodeLength::Tokens(8_000),
//! attack_surface: AttackSurface::MediumMinus.score(),
//! },
//! vulnerability_discovery: VulnerabilityDiscovery::new(
//! [Cwe::USE_AFTER_FREE, Cwe::TYPE_CONFUSION],
//! Score::lit(5.0),
//! Locality::SameCodebase.score(),
//! ),
//! exploit_development: ExploitDevelopment::with_technique_count(
//! Score::lit(6.0),
//! 1,
//! Score::lit(2.0),
//! ),
//! expert_knowledge: ExpertKnowledge::none(),
//! };
//!
//! let components = assessment.components();
//! assert_eq!(components.code_analysis, Score::lit(3.4));
//! assert_eq!(components.vulnerability_discovery, Score::lit(6.6));
//! assert_eq!(components.exploit_development, Score::lit(7.0));
//!
//! assert!((assessment.score().get() - 6.7965).abs() < 1e-4);
//! assert_eq!(assessment.score().level().to_string(), "Medium");
//! ```
//!
//! # The arithmetic
//!
//! Each component total is rounded to one decimal place *before* aggregation, which the
//! reference calculator does and which changes results.
//!
//! | Component | Total |
//! |---|---|
//! | Code analysis | `round1(readability × (lengthScore + attackSurface) / 20 / 3 + complexity × 2/3)` |
//! | Vulnerability discovery | `round1(min(10, complexity + cweCount) × 4/5 + locality / 5)` |
//! | Exploit development | `round1(max(min(10, complexity + techniqueCount), harness))` |
//! | Expert knowledge | `max` over required domains |
//!
//! Code length scores as `round1(clamp(log2(units / 500), 0, 10))`, counting `cl100k_base`
//! tokens for source and disassembly plus `.rodata` lines for binaries.
//!
//! Combining, for `m = max` and `s = sum` over the four totals:
//!
//! ```text
//! maxplus = 0 if m == 0 else m + (s - m) / (3 · m)
//! SOLVE = maxplus × 10 / 11
//! ```
//!
//! # Divergences from the prose specification
//!
//! Two places where the specification's text and its own reference calculator disagree. This
//! crate follows the calculator, because the published `DownUnderCTF` figures were produced by
//! it, and reproduces all sixteen exactly.
//!
//! 1. **Exploit development has no lower bound.** The prose clamps `complexity + techniques`
//! to `[1, 10]`; the calculator applies only the upper bound, and the published `pyny`
//! assessment scores zero on this component.
//! 2. **`maxplus` is not monotonic below 1.** The specification states the combined score is
//! monotonic in each component. It is not: raising a component can *lower* the score when
//! the maximum component is under `1.0`. Four components at `0.5` score `1.364`, but
//! raising one to `0.6` drops the result to `1.303`. The partial derivative in the maximum
//! parameter is `1 - (s - m) / (3m²)`, negative whenever `s - m > 3m²`, which requires
//! `m < 1`. Above `1.0` — every published example, and any challenge that is not trivial on
//! all four axes — monotonicity holds.
//!
//! # Attribution
//!
//! SOLVE: Scoring Obstacle Levels in Vulnerabilities & Exploits (Version 0.5) © 2025 by
//! Pattern Labs Tech Inc. (now Irregular) is licensed under CC BY-SA 4.0.
//!
//! This crate is an independent implementation of that specification, and is not affiliated with,
//! sponsored by, or endorsed by Irregular or Pattern Labs Tech Inc. A score produced here is not
//! an assessment by Irregular. Their own benchmarks are not public and are not implemented here.
//! See `NOTICE.md`.
pub use maxplus;
pub use ;
pub use SolveError;
pub use CodeLength;
pub use ;
pub use ;
/// A complete SOLVE assessment of one challenge.
/// The four component totals that feed the combined score.