test(server): add negative test for x-forwarded-host mismatch
Verifies the board mutation guard blocks requests when X-Forwarded-Host is present but Origin does not match it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d0e01d2863
commit
eb8c5d93e7
1 changed files with 11 additions and 0 deletions
|
|
@ -95,6 +95,17 @@ describe("boardMutationGuard", () => {
|
||||||
expect(res.status).toBe(204);
|
expect(res.status).toBe(204);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("blocks board mutations when x-forwarded-host does not match origin", async () => {
|
||||||
|
const app = createApp("board");
|
||||||
|
const res = await request(app)
|
||||||
|
.post("/mutate")
|
||||||
|
.set("Host", "127.0.0.1")
|
||||||
|
.set("X-Forwarded-Host", "10.90.10.20:3443")
|
||||||
|
.set("Origin", "https://evil.example.com")
|
||||||
|
.send({ ok: true });
|
||||||
|
expect(res.status).toBe(403);
|
||||||
|
});
|
||||||
|
|
||||||
it("does not block authenticated agent mutations", async () => {
|
it("does not block authenticated agent mutations", async () => {
|
||||||
const middleware = boardMutationGuard();
|
const middleware = boardMutationGuard();
|
||||||
const req = {
|
const req = {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue