Skip to content

Commit 08971ca

Browse files
committed
fix: 🔒 disallowed static_aliases outside current directory
Otherwise we could include `/etc/passwd`, which is **very** bad.
1 parent 30345f0 commit 08971ca

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/perseus/src/macros.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,16 @@ macro_rules! define_get_static_aliases {
117117
// We need to move this from being scoped to the app to being scoped for `.perseus/`
118118
// TODO make sure this works properly on Windows
119119
let resource = if resource.starts_with("/") {
120-
// Absolute paths should be left as is
121-
resource
120+
// Absolute paths are a security risk and are disallowed
121+
panic!("it's a security risk to include absolute paths in `static_aliases`");
122+
} else if resource.starts_with("../") {
123+
// Anything outside this directory is a security risk as well
124+
panic!("it's a security risk to include paths outside the current directory in `static_aliases`");
122125
} else if resource.starts_with("./") {
123-
// `./` -> `../`
126+
// `./` -> `../` (moving to execution from `.perseus/`)
124127
format!(".{}", resource)
125128
} else {
126-
// Anything else (including `../`) gets a `../` prepended
129+
// Anything else gets a `../` prepended
127130
format!("../{}", resource)
128131
};
129132
static_aliases.insert($url.to_string(), resource);

0 commit comments

Comments
 (0)