Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Add validation for R2 key

Edward Cuice812390a433
diff --git a/server/src/services/storage/r2StorageService.ts b/server/src/services/storage/r2StorageService.ts
index 97f05f264..eb9ca9c7e 100644
--- a/server/src/services/storage/r2StorageService.ts
+++ b/server/src/services/storage/r2StorageService.ts
@@ -285,6 +285,14 @@ class R2StorageService {
return;
}
+ if (key.trim().length === 0) {
+ throw new Error("Invalid storage key: key cannot be empty");
+ }
+
+ if (key.includes("..")) {
+ throw new Error("Invalid storage key: path traversal not allowed");
+ }
+
try {
await this.client.send(
new DeleteObjectCommand({