Add padding blob to data packs to mitigate chunking attacks#413
Add padding blob to data packs to mitigate chunking attacks#413
Conversation
| source: err, | ||
| })?; | ||
| let data_len_packed: u64 = len.into(); | ||
| self.stats.data_packed += data_len_packed; |
There was a problem hiding this comment.
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.
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.
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.
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-paddingwhich 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