Skip to content

Commit 3f61718

Browse files
committed
fix: prevent unrelated websites from modifying shortlinks via CSRF
Added two mitigations for this issue: - Attach an 'X-Requested-With' header in client requests - Make sure client POST requests have a content type of "application/json"
1 parent 043936a commit 3f61718

File tree

3 files changed

+47
-12
lines changed

3 files changed

+47
-12
lines changed

web/assets/lib/xhr.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ namespace xhr {
4848
export var create = (method: string, url: string) => {
4949
var xhr = new XMLHttpRequest();
5050
xhr.open(method, url, true);
51-
return new Req(xhr);
51+
52+
var req = new Req(xhr);
53+
return req.withHeader('X-Requested-With', 'XMLHttpRequest');
5254
};
5355

5456
export var get = (url: string) => {

web/bindata.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)