Skip to content

Commit e208b99

Browse files
committed
fix(security): verify dest_node uid matches signature
1 parent e840544 commit e208b99

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/backend/src/helpers.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ async function get_taskbar_items(user) {
15111511
return taskbar_items;
15121512
}
15131513

1514-
function validate_signature_auth(url, action) {
1514+
function validate_signature_auth(url, action, options = {}) {
15151515
const query = new URL(url).searchParams;
15161516

15171517
if(!query.get('uid'))
@@ -1522,6 +1522,12 @@ function validate_signature_auth(url, action) {
15221522
throw {message: '`expires` is required for signature-based authentication.'}
15231523
else if(!query.get('signature'))
15241524
throw {message: '`signature` is required for signature-based authentication.'}
1525+
1526+
if ( options.uid ) {
1527+
if ( query.get('uid') !== options.uid ) {
1528+
throw {message: 'Authentication failed. `uid` does not match.'}
1529+
}
1530+
}
15251531

15261532
const expired = query.get('expires') && (query.get('expires') < Date.now() / 1000);
15271533

src/backend/src/routers/writeFile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ module.exports = eggspress('/writeFile', {
9696
return;
9797
}
9898
try{
99-
validate_signature_auth(req.body.destination_write_url, 'write');
99+
validate_signature_auth(req.body.destination_write_url, 'write', {
100+
uid: req.body.destination_uid,
101+
});
100102
}catch(e){
101103
res.status(403).send(e);
102104
return;

0 commit comments

Comments
 (0)