Skip to content

Commit 0078273

Browse files
committed
sec chk
1 parent e8c0ea4 commit 0078273

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

spec/SecurityCheckGroups.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('Security Check Groups', () => {
4848
expect(group.checks()[5].checkState()).toBe(CheckState.success);
4949
expect(group.checks()[6].checkState()).toBe(CheckState.success);
5050
expect(group.checks()[8].checkState()).toBe(CheckState.success);
51+
expect(group.checks()[9].checkState()).toBe(CheckState.success);
5152
});
5253

5354
it('checks fail correctly', async () => {
@@ -59,6 +60,13 @@ describe('Security Check Groups', () => {
5960
config.mountPlayground = true;
6061
config.readOnlyMasterKey = 'someReadOnlyMasterKey';
6162
config.readOnlyMasterKeyIps = ['0.0.0.0/0'];
63+
config.requestComplexity = {
64+
includeDepth: -1,
65+
includeCount: -1,
66+
subqueryDepth: -1,
67+
graphQLDepth: -1,
68+
graphQLFields: -1,
69+
};
6270
await reconfigureServer(config);
6371

6472
const group = new CheckGroupServerConfig();
@@ -70,6 +78,7 @@ describe('Security Check Groups', () => {
7078
expect(group.checks()[5].checkState()).toBe(CheckState.fail);
7179
expect(group.checks()[6].checkState()).toBe(CheckState.fail);
7280
expect(group.checks()[8].checkState()).toBe(CheckState.fail);
81+
expect(group.checks()[9].checkState()).toBe(CheckState.fail);
7382
});
7483

7584
it_only_db('mongo')('checks succeed correctly (MongoDB specific)', async () => {

src/Security/CheckGroups/CheckGroupServerConfig.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,23 @@ class CheckGroupServerConfig extends CheckGroup {
134134
}
135135
},
136136
}),
137+
new Check({
138+
title: 'Request complexity limits enabled',
139+
warning:
140+
'One or more request complexity limits are disabled, which may allow denial-of-service attacks through deeply nested or excessively broad queries.',
141+
solution:
142+
"Ensure all properties in 'requestComplexity' are set to positive integers. Set to '-1' only if you have other mitigations in place.",
143+
check: () => {
144+
const rc = config.requestComplexity;
145+
if (!rc) {
146+
throw 1;
147+
}
148+
const values = [rc.includeDepth, rc.includeCount, rc.subqueryDepth, rc.graphQLDepth, rc.graphQLFields];
149+
if (values.some(v => v === -1)) {
150+
throw 1;
151+
}
152+
},
153+
}),
137154
new Check({
138155
title: 'LiveQuery regex timeout enabled',
139156
warning:

0 commit comments

Comments
 (0)