mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 21:30:30 +01:00
fix: vulnerability in socket.io nested namespaces (#11117)
This commit is contained in:
committed by
GitHub
parent
1ea9481af6
commit
586eed1407
@@ -123,7 +123,7 @@ async function onMessage(socket, payload) {
|
||||
const parts = eventName.toString().split('.');
|
||||
const namespace = parts[0];
|
||||
const methodToCall = parts.reduce((prev, cur) => {
|
||||
if (prev !== null && prev[cur]) {
|
||||
if (prev !== null && prev[cur] && (!prev.hasOwnProperty || prev.hasOwnProperty(cur))) {
|
||||
return prev[cur];
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -91,6 +91,22 @@ describe('socket.io', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error for unknown event', (done) => {
|
||||
io.emit('user.gdpr.__proto__.constructor.toString', (err) => {
|
||||
assert(err);
|
||||
assert.equal(err.message, '[[error:invalid-event, user.gdpr.__proto__.constructor.toString]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error for unknown event', (done) => {
|
||||
io.emit('constructor.toString', (err) => {
|
||||
assert(err);
|
||||
assert.equal(err.message, '[[error:invalid-event, constructor.toString]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get installed themes', (done) => {
|
||||
const themes = ['nodebb-theme-lavender', 'nodebb-theme-persona', 'nodebb-theme-vanilla'];
|
||||
io.emit('admin.themes.getInstalled', (err, data) => {
|
||||
|
||||
Reference in New Issue
Block a user