|
| 1 | +# Security Fix: RUSTSEC-2026-0002 |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +Fixed a soundness vulnerability in the `lru` crate (version 0.12.5) used as a transitive dependency through `iced_glyphon`. |
| 6 | + |
| 7 | +## Vulnerability Details |
| 8 | + |
| 9 | +- **Advisory**: RUSTSEC-2026-0002 |
| 10 | +- **Package**: `lru` |
| 11 | +- **Affected Versions**: 0.9.0 to 0.16.2 (inclusive) |
| 12 | +- **Patched Version**: 0.16.3+ |
| 13 | +- **Severity**: Unsound (memory safety issue) |
| 14 | +- **Issue**: `IterMut` violates Stacked Borrows by invalidating internal pointer |
| 15 | + |
| 16 | +### Technical Description |
| 17 | + |
| 18 | +The `IterMut` iterator implementation in the vulnerable lru versions temporarily creates an exclusive reference (`&mut`) to the key when dereferencing the internal node pointer. This invalidates the shared pointer (`&`) held by the internal `HashMap`, violating Rust's Stacked Borrows rules and potentially causing undefined behavior. |
| 19 | + |
| 20 | +## Dependency Chain |
| 21 | + |
| 22 | +``` |
| 23 | +rustirc v0.3.8 |
| 24 | +└── rustirc-gui v0.3.8 |
| 25 | + └── iced v0.13.1 |
| 26 | + └── iced_wgpu v0.13.5 |
| 27 | + └── iced_glyphon v0.6.0 |
| 28 | + └── lru v0.12.5 ← VULNERABLE |
| 29 | +``` |
| 30 | + |
| 31 | +## Solution Implemented |
| 32 | + |
| 33 | +Since `iced_glyphon` v0.6.0 depends on `lru ^0.12.1` and there's no newer version of `iced_glyphon` available that uses the patched lru, we implemented a vendor patch: |
| 34 | + |
| 35 | +1. **Downloaded** `iced_glyphon` v0.6.0 source code |
| 36 | +2. **Modified** `Cargo.toml` to update lru dependency from `0.12.1` to `0.16.3` |
| 37 | +3. **Vendored** the patched version in `vendor/iced_glyphon/` |
| 38 | +4. **Applied** Cargo patch in workspace `Cargo.toml`: |
| 39 | + ```toml |
| 40 | + [patch.crates-io] |
| 41 | + iced_glyphon = { path = "vendor/iced_glyphon" } |
| 42 | + ``` |
| 43 | + |
| 44 | +## Verification |
| 45 | + |
| 46 | +Before fix: |
| 47 | +``` |
| 48 | +lru v0.12.5 ← Vulnerable |
| 49 | +└── iced_glyphon v0.6.0 |
| 50 | +``` |
| 51 | + |
| 52 | +After fix: |
| 53 | +``` |
| 54 | +lru v0.16.3 ← Patched |
| 55 | +└── iced_glyphon v0.6.0 (vendored) |
| 56 | +``` |
| 57 | + |
| 58 | +## Testing |
| 59 | + |
| 60 | +- ✅ Clean build successful |
| 61 | +- ✅ All tests passing |
| 62 | +- ✅ Clippy clean (no warnings) |
| 63 | +- ✅ No vulnerable lru versions in dependency tree |
| 64 | + |
| 65 | +## Future Maintenance |
| 66 | + |
| 67 | +This vendor patch can be removed when: |
| 68 | +- `iced_glyphon` releases a version with lru 0.16.3+ |
| 69 | +- Upgrading to iced 0.14+ (which may use different text rendering) |
| 70 | +- Switching to `cryoglyph` (iced-rs fork with updated dependencies) |
| 71 | + |
| 72 | +## References |
| 73 | + |
| 74 | +- RustSec Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0002 |
| 75 | +- GitHub Advisory: https://github.com/advisories/GHSA-rhfx-m35p-ff5j |
| 76 | +- lru-rs Fix PR: https://github.com/jeromefroe/lru-rs/pull/224 |
| 77 | +- Affected Package: https://crates.io/crates/lru/0.12.5 |
| 78 | +- Patched Package: https://crates.io/crates/lru/0.16.3 |
| 79 | + |
| 80 | +## Files Modified |
| 81 | + |
| 82 | +- `Cargo.toml`: Added `[patch.crates-io]` section |
| 83 | +- `Cargo.lock`: Updated lru dependency to 0.16.3 |
| 84 | +- `vendor/`: Added patched iced_glyphon source |
| 85 | +- `vendor/README.md`: Documentation for vendored dependencies |
0 commit comments