Commit 8cadb61
committed
Add audit hooks for pickle.load, pickle.loads, and pickle.Unpickler
Add sys.audit / PySys_Audit calls for deserialization entry points in
the pickle module to allow security monitoring of pickle usage. This
complements the existing pickle.find_class audit event by providing
visibility into when pickle deserialization is initiated, not just when
classes are resolved during unpickling.
New audit events:
- pickle.load(file): raised when pickle.load() is called
- pickle.loads(data): raised when pickle.loads() is called
- pickle.Unpickler(file): raised when an Unpickler is instantiated
These hooks are implemented in both the Python (Lib/pickle.py) and C
(Modules/_pickle.c) implementations.
https://claude.ai/code/session_01HKopnL4QijaMQU4drGEefL1 parent e1dbe22 commit 8cadb61
4 files changed
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
242 | 247 | | |
243 | 248 | | |
244 | 249 | | |
| |||
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| 259 | + | |
| 260 | + | |
254 | 261 | | |
255 | 262 | | |
256 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
257 | 267 | | |
258 | 268 | | |
259 | 269 | | |
| |||
417 | 427 | | |
418 | 428 | | |
419 | 429 | | |
| 430 | + | |
| 431 | + | |
420 | 432 | | |
421 | 433 | | |
422 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
423 | 438 | | |
424 | 439 | | |
425 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1218 | 1218 | | |
1219 | 1219 | | |
1220 | 1220 | | |
| 1221 | + | |
1221 | 1222 | | |
1222 | 1223 | | |
1223 | 1224 | | |
| |||
1803 | 1804 | | |
1804 | 1805 | | |
1805 | 1806 | | |
| 1807 | + | |
1806 | 1808 | | |
1807 | 1809 | | |
1808 | 1810 | | |
1809 | 1811 | | |
1810 | 1812 | | |
1811 | 1813 | | |
1812 | 1814 | | |
| 1815 | + | |
1813 | 1816 | | |
1814 | 1817 | | |
1815 | 1818 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
156 | 172 | | |
157 | 173 | | |
158 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7287 | 7287 | | |
7288 | 7288 | | |
7289 | 7289 | | |
| 7290 | + | |
| 7291 | + | |
| 7292 | + | |
| 7293 | + | |
7290 | 7294 | | |
7291 | 7295 | | |
7292 | 7296 | | |
| |||
7811 | 7815 | | |
7812 | 7816 | | |
7813 | 7817 | | |
| 7818 | + | |
| 7819 | + | |
| 7820 | + | |
| 7821 | + | |
| 7822 | + | |
7814 | 7823 | | |
7815 | 7824 | | |
7816 | 7825 | | |
| |||
7872 | 7881 | | |
7873 | 7882 | | |
7874 | 7883 | | |
| 7884 | + | |
| 7885 | + | |
| 7886 | + | |
| 7887 | + | |
| 7888 | + | |
7875 | 7889 | | |
7876 | 7890 | | |
7877 | 7891 | | |
| |||
0 commit comments