This repository was archived by the owner on Jun 18, 2026. It is now read-only.
Commit 17b2c04
committed
security(GraphAnnotationManager): pre-read file size check to prevent OOM (CWE-400)
importFromFile() previously read the entire file into a StringBuilder
before importFromJson()'s character-count guard could fire. A multi-GB
adversarial file would exhaust the JVM heap before the size limit was
ever checked.
Fix:
- Check file.length() against MAX_IMPORT_SIZE BEFORE reading
- Add belt-and-suspenders character count check during read loop
- Pre-size StringBuilder from file.length() to avoid reallocation
- Remove incorrect ExportUtils.validateOutputPath() call on an input
file (it's a read operation, not a write — the output-path validator
was incorrectly restricting which files could be imported)1 parent e322996 commit 17b2c04
1 file changed
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
522 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
523 | 525 | | |
524 | 526 | | |
525 | 527 | | |
526 | 528 | | |
527 | | - | |
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
533 | 534 | | |
534 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
535 | 545 | | |
536 | 546 | | |
537 | 547 | | |
538 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
539 | 555 | | |
540 | 556 | | |
541 | 557 | | |
| |||
0 commit comments