feat: reject custom CSS that references external resources
Reject status page custom CSS containing @import or a url() / image-set() / image() / cross-fade() whose target is http(s) or protocol-relative, while allowing data: and relative URLs. The check normalizes comments and CSS escapes first so obfuscated forms cannot slip past. Enforced in the create/update body validation.
This commit is contained in:
1 parent
6165ae60e6
commit
3685e0c476
4 files changed
+101
-1
No files matched your search
@@ -48,4 +48,16 @@ describe("createStatusPageBodyValidation", () => {
|
||||
const result = createStatusPageBodyValidation.safeParse(baseCreateBody({ customCSS: 42 }));
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects customCSS that references an external resource", () => {
|
||||
const result = createStatusPageBodyValidation.safeParse(baseCreateBody({ customCSS: 'body{background:url("https://evil.example/beacon")}' }));
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(result.error.issues).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ message: "Custom CSS cannot reference external URLs or use @import", path: ["customCSS"] }),
|
||||
])
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user