Skip to content

Commit 8c71f31

Browse files
committed
If the incoming request has app id specified both in the header AND the JSON body, then check that both are the same. Flag the request as invalid if they are not the same. If the app id is not specified in the headers, then pick it up from the JSON body. Moreover, remove the app config keys (app id, master key, js key, .net key etc.) from the request body unconditionally - ie. even if those are specified in the header. This is so that if the proxy fronting the app is not able these keys from the body. Signed-off-by: Kunal Gangakhedkar <[email protected]>
1 parent 9a14f53 commit 8c71f31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

middlewares.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function handleParseHeaders(req, res, next) {
2828

2929
var fileViaJSON = false;
3030

31-
if (!info.appId || !cache.apps[info.appId]) {
3231
// See if we can find the app id on the body.
3332
if (req.body instanceof Buffer) {
3433
// The only chance to find the app id is if this is a file
@@ -44,7 +43,11 @@ function handleParseHeaders(req, res, next) {
4443
||
4544
cache.apps[req.body._ApplicationId]['masterKey'] === info.masterKey)
4645
) {
47-
info.appId = req.body._ApplicationId;
46+
if ((info.appId) && (info.appId !== req.body._ApplicationId))
47+
return invalidRequest(req, res);
48+
else if (!info.appId)
49+
info.appId = req.body._ApplicationId;
50+
4851
info.javascriptKey = req.body._JavaScriptKey || '';
4952
delete req.body._ApplicationId;
5053
delete req.body._JavaScriptKey;
@@ -69,7 +72,6 @@ function handleParseHeaders(req, res, next) {
6972
} else {
7073
return invalidRequest(req, res);
7174
}
72-
}
7375

7476
if (fileViaJSON) {
7577
// We need to repopulate req.body with a buffer

0 commit comments

Comments
 (0)