Skip to content

Commit dabc70b

Browse files
committed
web: upload_cert_bundle_handler: validate content-type
1 parent 08d5925 commit dabc70b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/web.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,22 @@ async fn upload_hex_model_handler(
348348

349349
pub async fn upload_cert_bundle_handler(
350350
State(_state): State<Arc<AppState>>,
351-
_headers: HeaderMap,
351+
headers: HeaderMap,
352352
RawBody(body): RawBody,
353353
) -> impl IntoResponse {
354+
// Validate Content-Type header
355+
let content_type = headers
356+
.get("content-type")
357+
.and_then(|ct| ct.to_str().ok())
358+
.unwrap_or("");
359+
360+
if content_type != "application/gzip" && content_type != "application/x-gzip" {
361+
return (
362+
StatusCode::UNSUPPORTED_MEDIA_TYPE,
363+
format!("Unsupported Content-Type: {}", content_type),
364+
);
365+
}
366+
354367
// Read request body into bytes
355368
let body_bytes = match hyper::body::to_bytes(body).await {
356369
Ok(bytes) => bytes,

0 commit comments

Comments
 (0)