Reject unsafe file extensions
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
parent
80b2bd2d14
commit
f86c7d69db
1 changed files with 12 additions and 0 deletions
12
src/lib.rs
12
src/lib.rs
|
@ -992,6 +992,18 @@ impl<C: UpstreamClient + 'static, S: Sandboxing + Send + Sync + 'static> App<C,
|
||||||
where
|
where
|
||||||
<<C as UpstreamClient>::Response as HTTPResponse>::BodyStream: Unpin,
|
<<C as UpstreamClient>::Response as HTTPResponse>::BodyStream: Unpin,
|
||||||
{
|
{
|
||||||
|
if let Some(ext) = filename.split('.').last() {
|
||||||
|
if [
|
||||||
|
"exe", "com", "dll", "sys", "bat", "cmd", "sh", "bash", "zsh", "fish", "ps1",
|
||||||
|
"psm1", "elf", "so", "dylib", "dmg", "scr", "url", "app", "jar", "apk", "msi",
|
||||||
|
"deb", "rpm", "rpm", "pkg",
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
.any(|x| x.eq_ignore_ascii_case(ext))
|
||||||
|
{
|
||||||
|
return Err(ErrorResponse::unsafe_media());
|
||||||
|
}
|
||||||
|
}
|
||||||
Self::proxy_impl(method, Some(&filename), State(state), Query(query), info).await
|
Self::proxy_impl(method, Some(&filename), State(state), Query(query), info).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue