-
-
Notifications
You must be signed in to change notification settings - Fork 71
feat(variables): Begin reading minidump memory for variables #2035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| mod caches; | ||
| pub mod interface; | ||
| mod memory; | ||
| mod metrics; | ||
| mod symbolication; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| use minidump::Minidump; | ||
| use scroll::ctx::{SizeWith, TryFromCtx}; | ||
| use symbolic::common::ByteView; | ||
|
|
||
| /// Unified memory access for crash dumps. | ||
| pub trait MemoryAccess: std::fmt::Debug + Send + Sync { | ||
| /// Attempts to lookup a memory range at the specified `addr` with the specified size. | ||
| fn get_memory_at_address(&self, addr: u64, size: usize) -> Option<&'_ [u8]>; | ||
|
|
||
| /// The endianness of the crash. | ||
| fn endian(&self) -> scroll::Endian; | ||
| } | ||
|
|
||
| impl MemoryAccess for Minidump<'static, ByteView<'static>> { | ||
| fn get_memory_at_address(&self, addr: u64, size: usize) -> Option<&'_ [u8]> { | ||
| let memory = self.get_memory()?; | ||
| let memory = memory.memory_at_address(addr)?; | ||
|
|
||
| let start = addr.checked_sub(memory.base_address())? as usize; | ||
| let end = start.checked_add(size)?; | ||
|
|
||
| match memory { | ||
| minidump::UnifiedMemory::Memory(region) => region.bytes.get(start..end), | ||
| minidump::UnifiedMemory::Memory64(region) => region.bytes.get(start..end), | ||
| } | ||
| } | ||
|
|
||
| fn endian(&self) -> scroll::Endian { | ||
| self.endian | ||
| } | ||
| } | ||
|
|
||
| /// Extension trait for [`MemoryAccess`]. | ||
| pub trait MemoryAccessExt: MemoryAccess { | ||
| /// Helper which accesses the memory of a dump and converts the memory to the specified type. | ||
| fn get_value_at_address<T>(&self, addr: u64) -> Option<T> | ||
| where | ||
| T: SizeWith<scroll::Endian>, | ||
| for<'a> T: TryFromCtx<'a, scroll::Endian>, | ||
| { | ||
| let endian = self.endian(); | ||
| let size = T::size_with(&endian); | ||
| let memory = self.get_memory_at_address(addr, size)?; | ||
|
|
||
| T::try_from_ctx(memory, endian).ok().map(|(value, _)| value) | ||
| } | ||
| } | ||
|
|
||
| impl<T: MemoryAccess + ?Sized> MemoryAccessExt for T {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable extraction materializes attacker-sized memory dumps without an output cap
When variable extraction is enabled, a SymCache-derived primitive or pointer size controls the minidump range read for a frame-offset variable. Although the memory accessor checks that the range exists, a successful range can be as large as the accepted dump and
format!("{s:?}")materializes an uncapped, substantially larger String that is retained in the response, potentially exhausting worker memory.Evidence
/minidumpand/symbolicate-anyacceptoptions.extract_variables; minidump processing passesSome(Arc::new(minidump))as the memory source to native symbolication (crates/symbolicator/src/endpoints/minidump.rs:47-50,crates/symbolicator-native/src/symbolication/process_minidump.rs:672-676).resolve_variable_valueobtainsTypeSize::Bytes(size)from SymCache primitive/pointer types and uses that value forFrameOffsetmemory access (crates/symbolicator-native/src/symbolication/native.rs:212-215,231-257); no application-level maximum is applied tosize.get_memory_at_addresssafely rejects ranges beyond the mapped memory region, but a valid range may still span the dump's large memory region (crates/symbolicator-native/src/memory.rs:15-27). The fallback then Debug-formats every byte into an owned String with no output cap (crates/symbolicator-native/src/symbolication/native.rs:255-257), and the String is retained in the variables map at lines 185-195.crates/symbolicator-service/src/config.rs:663-665), which limits input bytes but not the formatted output or serialization work; the remote attachment path additionally streams the storage response without applying that limit (crates/symbolicator-native/src/symbolication/attachments.rs:36-52).Also found at 1 additional location
crates/symbolicator-native/src/symbolication/native.rs:256-258Identified by Warden · wrdn-dos-review · 88N-CRQ