Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion camera_hub/src/delivery_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl DeliveryMonitor {

pub fn get_thumbnail_file_path(&self, info: &ThumbnailMetaInfo) -> PathBuf {
let video_dir_path = Path::new(&self.thumbnail_dir);
video_dir_path.join(&info.filename)
video_dir_path.join(ThumbnailMetaInfo::get_filename_from_timestamp(info.timestamp))
}

pub fn get_enc_video_file_path(&self, info: &VideoInfo) -> PathBuf {
Expand Down
5 changes: 3 additions & 2 deletions camera_hub/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,9 @@ fn core(
info!("Starting to save and send video thumbnail");
let thumbnail_info =
ThumbnailMetaInfo::new(video_info.timestamp, 0, motion_event.detections); //0 epoch = unset
let thumbnail_file =
camera.get_thumbnail_dir() + "/" + &*thumbnail_info.filename.clone();
let thumbnail_file = camera.get_thumbnail_dir()
+ "/"
+ &ThumbnailMetaInfo::get_filename_from_timestamp(thumbnail_info.timestamp);
thumbnail_image
.save(thumbnail_file)
.expect("Failed to save thumbnail PNG file");
Expand Down
2 changes: 0 additions & 2 deletions client_lib/src/thumbnail_meta_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub struct ThumbnailMetaInfo {
pub detections: Vec<GeneralDetectionType>,
pub sanity: String,
pub epoch: u64,
pub filename: String,
}

pub const THUMBNAIL_SANITY: &str = "thumbbeef";
Expand All @@ -32,7 +31,6 @@ impl ThumbnailMetaInfo {
detections,
sanity: THUMBNAIL_SANITY.to_string(),
epoch: thumbnail_epoch,
filename: Self::get_filename_from_timestamp(timestamp),
}
}

Expand Down
4 changes: 3 additions & 1 deletion client_lib/src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ pub fn decrypt_thumbnail_file(
}
}

let dec_filename: String = thumbnail_meta_info.filename;
// Do not trust the sender-provided filename here.
// The timestamp is the stable identifier for thumbnails, and deriving the path from it prevents path traversal through attacker-crafted metadata.
let dec_filename = ThumbnailMetaInfo::get_filename_from_timestamp(thumbnail_meta_info.timestamp);
let dec_pathname: String = format!("{}/videos/{}", file_dir, dec_filename);

if Path::new(&dec_pathname).exists() {
Expand Down
Loading