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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//! `writ` - CPU symbolic execution and exploit witness construction.
//!
//! A writ is a written compulsion of evidence. This crate produces
//! exactly that: given a source→sink path proven by `weir`, it
//! synthesizes a concrete input that drives execution along the path
//! and triggers the attacker constraint at the sink. The output is a
//! Class 1 finding for surgec - not "I think there's a SQL injection
//! here" but "here is the curl command that triggers it."
//!
//! `writ` is a wrapper around vyre - it consumes vyre IR and weir
//! paths. It is **not** part of the `vyre-*` namespace. The companion
//! GPU-resident wrapper is `scry`, which lives in a separate crate so
//! CPU primitives cannot leak into the GPU code path. See
//! `vyre/VISION.md` "The wrapper namespace and its closed-set rule."
//!
//! ## Architecture
//!
//! Surgec consumes `WitnessProvider` (the trait). Backends register
//! themselves under feature flags:
//!
//! ```text
//! WitnessProvider trait
//! ↓
//! Z3Backend (cfg(feature = "z3-backend"), the default)
//! ↓
//! z3 crate → libz3 (system C++ library)
//! ```
//!
//! Future backends (`cvc5`, `bitwuzla`) plug in behind the same trait
//! the same way. The GPU-resident equivalent lives in `scry` and
//! satisfies the same trait while sharing zero implementation code.
//!
//! ## What's implemented today
//!
//! - The `WitnessProvider` trait surface
//! - `WitnessRequest` / `WitnessOutcome` / `ConcreteInput` types
//! - `SinkConstraintKind` enum - SQLi / cmd-injection / SSRF / XXE /
//! path-traversal / deserialization / template-injection (the
//! sink-payload library is one TOML per kind, parsed at runtime)
//! - Z3 backend skeleton: opens a `z3::Solver`, declares free
//! variables for path-input bytes, encodes a placeholder constraint,
//! solves, returns the model
//!
//! ## What's not implemented yet (deliberately, by scope)
//!
//! - Per-language statement→SMT encoders (one per language: C, Python,
//! JS, Go, Java, Ruby, PHP, Kotlin, Swift, C#). Each is its own
//! substantial body of work; lands in subsequent sessions.
//! - The full sink-payload TOML library
//! - Concolic fallback for paths longer than the symbolic budget
//! - Input rendering (SMT model → curl command / JSON body / argv)
/// Identifies which sink class a witness must satisfy. Each kind has
/// a TOML in `rules/sinks/<kind>.toml` declaring the exploit
/// constraint shape (e.g. for SQLi: "the value reaching the sink
/// contains an unquoted SQL operator that escapes the surrounding
/// string literal").
/// Per-shape parameters that the trivial-encoder needs from the rule's
/// path-bound variables. Surgec populates this from `weir`'s slot
/// extraction at proof-assembly time. None for shapes that don't take
/// shape-specific parameters.
/// A request to synthesize an exploit witness. Built by surgec from a
/// weir path + a rule's declared sink kind.
/// One statement on a weir path.
/// File + byte-range location.
/// The output of a successful witness construction.
/// Categorizes how the input is delivered to the program.
/// Outcome of a witness attempt.
/// The trait surgec consumes. Both `writ` (CPU/Z3) and `scry` (GPU/
/// vyre-native) implement this - surgec is backend-agnostic.
/// Per-sink-class trivial witness encoders. Ships the closed-form
/// witnesses for stack-overflow / gets / format-string shapes -
/// shapes whose witness is mechanically derivable from path-bound
/// variables without an SMT solver. Other sink kinds route through
/// the Z3 backend.
pub use ;
pub use Z3Backend;