Commit aa61689
committed
Add audit hooks for pickle.load, pickle.loads, and pickle.Unpickler
Add sys.audit() / PySys_Audit() calls to pickle deserialization entry
points, allowing security-conscious applications to monitor or block
pickle deserialization via audit hooks.
New audit events:
- pickle.load: raised when pickle.load() is called, with the file arg
- pickle.loads: raised when pickle.loads() is called, with the data arg
- pickle.Unpickler: raised when Unpickler is instantiated, with file arg
These are added to both the pure Python (Lib/pickle.py) and C
(Modules/_pickle.c) implementations, following the same pattern as
the existing pickle.find_class audit event and marshal module auditing.
https://claude.ai/code/session_016rSSYy6CqG9hJZk7uzZYZ91 parent 149c465 commit aa61689
5 files changed
Lines changed: 51 additions & 0 deletions
File tree
- Doc/library
- Lib
- test
- Misc/NEWS.d/next/Security
- Modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
| |||
258 | 260 | | |
259 | 261 | | |
260 | 262 | | |
| 263 | + | |
| 264 | + | |
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
| |||
433 | 437 | | |
434 | 438 | | |
435 | 439 | | |
| 440 | + | |
| 441 | + | |
436 | 442 | | |
437 | 443 | | |
438 | 444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1314 | 1314 | | |
1315 | 1315 | | |
1316 | 1316 | | |
| 1317 | + | |
1317 | 1318 | | |
1318 | 1319 | | |
1319 | 1320 | | |
| |||
1909 | 1910 | | |
1910 | 1911 | | |
1911 | 1912 | | |
| 1913 | + | |
1912 | 1914 | | |
1913 | 1915 | | |
1914 | 1916 | | |
1915 | 1917 | | |
1916 | 1918 | | |
1917 | 1919 | | |
1918 | 1920 | | |
| 1921 | + | |
1919 | 1922 | | |
1920 | 1923 | | |
1921 | 1924 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
155 | 156 | | |
156 | 157 | | |
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 | + | |
158 | 187 | | |
159 | 188 | | |
160 | 189 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7514 | 7514 | | |
7515 | 7515 | | |
7516 | 7516 | | |
| 7517 | + | |
| 7518 | + | |
| 7519 | + | |
7517 | 7520 | | |
7518 | 7521 | | |
7519 | 7522 | | |
| |||
8043 | 8046 | | |
8044 | 8047 | | |
8045 | 8048 | | |
| 8049 | + | |
| 8050 | + | |
| 8051 | + | |
8046 | 8052 | | |
8047 | 8053 | | |
8048 | 8054 | | |
| |||
8104 | 8110 | | |
8105 | 8111 | | |
8106 | 8112 | | |
| 8113 | + | |
| 8114 | + | |
| 8115 | + | |
8107 | 8116 | | |
8108 | 8117 | | |
8109 | 8118 | | |
| |||
0 commit comments