-
Notifications
You must be signed in to change notification settings - Fork 25
Add padding blob to data packs to mitigate chunking attacks #413
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
base: main
Are you sure you want to change the base?
Conversation
source: err, | ||
})?; | ||
let data_len_packed: u64 = len.into(); | ||
self.stats.data_packed += data_len_packed; |
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.
What do you think about just self.stats.data_packed += len
?
// Add a padding blob | ||
fn add_padding_blob(&mut self) -> RusticResult<()> { | ||
pub(super) const KB: u32 = 1024; | ||
pub(super) const MAX_PADDING: u32 = 64 * KB; |
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.
redundant definition of these conts (defined above in constants
inlined module)
let data = vec![ | ||
0; | ||
padding_size | ||
.try_into() | ||
.expect("u32 should convert to usize") | ||
]; |
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.
As your "except" message says, to me there will never be an issue with converting padding_size
to usize
:
let data = vec![ | |
0; | |
padding_size | |
.try_into() | |
.expect("u32 should convert to usize") | |
]; | |
let data = vec![0; padding_size as usize]; |
fn padding_size(size: u32) -> u32 { | ||
// compute padding size. Note that we don't add zero-sized blobs here, i.e. padding_size is in 1..=MAX_PADDING. | ||
let padding = constants::MAX_PADDING - size % constants::MAX_PADDING; | ||
if padding == 0 { | ||
constants::MAX_PADDING | ||
} else { | ||
padding | ||
} | ||
} |
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.
I took a look at the restic PR for padding attack resilience, it seems they implemented the "padmé" padding "size" algorithm for this.
They reference this blogpost https://lbarman.ch/blog/padme/ and it seems interesting (you probably already have seen it since you participated in the restic issue on chunking attacks).
What's your opinion on that?
I am not strongly opinionated on this, but it seems that padmé is a thought through padding algorithm with a good balance between security and overhead.
see e.g. rustic-rs/rustic#1439
This also introduces the repository config option
use-pack-padding
which allows to disable the padding.As a side-effect currently wrong statistics (data added to blobs in stats was without pack header) has been corrected.
depends on #409