Commit c2bfd7b
authored
fix: honor SSE-C chunk offsets in decryption for large chunked uploads (seaweedfs#8216)
* fix: honor SSE-C chunk offsets in decryption for large chunked uploads
Fixes issue seaweedfs#8215 where SSE-C decryption for large objects could corrupt
data by ignoring per-chunk PartOffset values.
Changes:
- Add TestSSECLargeObjectChunkReassembly unit test to verify correct
decryption of 19MB object split into 8MB chunks using PartOffset
- Update decryptSSECChunkView and createMultipartSSECDecryptedReaderDirect
to extract PartOffset from SSE-C metadata and pass to
CreateSSECDecryptedReaderWithOffset for offset-aware decryption
- Fix createCTRStreamWithOffset to use calculateIVWithOffset for proper
block-aligned counter advancement, matching SSE-KMS/S3 behavior
- Update comments to clarify SSE-C IV handling uses per-chunk offsets
(unlike base IV approach used by KMS/S3)
All tests pass: go test ./weed/s3api ✓
* fix: close chunkReader on error paths in createMultipartSSECDecryptedReader
Address resource leak issue reported in PR seaweedfs#8216: ensure chunkReader is
properly closed before returning on all error paths, including:
- DeserializeSSECMetadata failures
- IV decoding errors
- Invalid PartOffset values
- SSE-C reader creation failures
- Missing per-chunk metadata
This prevents leaking network connections and file handles during
SSE-C multipart decryption error scenarios.
* docs: clarify SSE-C IV handling in decryptSSECChunkView comment
Replace misleading warning 'Do NOT call calculateIVWithOffset' with
accurate explanation that:
- CreateSSECDecryptedReaderWithOffset internally uses calculateIVWithOffset
to advance the CTR counter to reach PartOffset
- calculateIVWithOffset is applied only to the per-part IV, NOT to derive
a global base IV for all parts
- This differs fundamentally from SSE-KMS/SSE-S3 which use base IV +
calculateIVWithOffset(ChunkOffset)
This clarifies the IV advancement mechanism while contrasting it with
the base IV approach used by other encryption schemes.1 parent 19c18d8 commit c2bfd7b
File tree
3 files changed
+95
-33
lines changed- weed/s3api
3 files changed
+95
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
278 | 273 | | |
279 | 274 | | |
280 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
425 | 477 | | |
426 | 478 | | |
427 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1512 | 1512 | | |
1513 | 1513 | | |
1514 | 1514 | | |
1515 | | - | |
| 1515 | + | |
1516 | 1516 | | |
1517 | | - | |
1518 | | - | |
| 1517 | + | |
| 1518 | + | |
1519 | 1519 | | |
1520 | | - | |
| 1520 | + | |
1521 | 1521 | | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
1526 | 1527 | | |
1527 | 1528 | | |
1528 | 1529 | | |
| |||
1544 | 1545 | | |
1545 | 1546 | | |
1546 | 1547 | | |
1547 | | - | |
1548 | | - | |
1549 | | - | |
1550 | | - | |
1551 | | - | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
1552 | 1556 | | |
1553 | 1557 | | |
1554 | 1558 | | |
| |||
2844 | 2848 | | |
2845 | 2849 | | |
2846 | 2850 | | |
2847 | | - | |
2848 | | - | |
| 2851 | + | |
| 2852 | + | |
2849 | 2853 | | |
2850 | 2854 | | |
2851 | 2855 | | |
2852 | 2856 | | |
2853 | 2857 | | |
2854 | 2858 | | |
2855 | | - | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
2856 | 2865 | | |
2857 | 2866 | | |
2858 | 2867 | | |
| |||
3235 | 3244 | | |
3236 | 3245 | | |
3237 | 3246 | | |
| 3247 | + | |
3238 | 3248 | | |
3239 | 3249 | | |
3240 | 3250 | | |
3241 | 3251 | | |
3242 | 3252 | | |
3243 | 3253 | | |
| 3254 | + | |
3244 | 3255 | | |
3245 | 3256 | | |
3246 | 3257 | | |
3247 | | - | |
3248 | | - | |
3249 | | - | |
3250 | | - | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
3251 | 3263 | | |
3252 | | - | |
| 3264 | + | |
| 3265 | + | |
3253 | 3266 | | |
| 3267 | + | |
3254 | 3268 | | |
3255 | 3269 | | |
3256 | 3270 | | |
3257 | 3271 | | |
| 3272 | + | |
3258 | 3273 | | |
3259 | 3274 | | |
3260 | 3275 | | |
| |||
0 commit comments