mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Security: Fix revision parsing (#5772)
A carefully crated URL can cause Etherpad to hang.
This commit is contained in:
parent
1d289520eb
commit
1e98033632
9 changed files with 325 additions and 29 deletions
|
@ -39,6 +39,7 @@ const stats = require('../stats');
|
|||
const assert = require('assert').strict;
|
||||
const {RateLimiterMemory} = require('rate-limiter-flexible');
|
||||
const webaccess = require('../hooks/express/webaccess');
|
||||
const { checkValidRev } = require('../utils/checkValidRev');
|
||||
|
||||
let rateLimiter;
|
||||
let socketio = null;
|
||||
|
@ -1076,10 +1077,14 @@ const handleChangesetRequest = async (socket, {data: {granularity, start, reques
|
|||
if (granularity == null) throw new Error('missing granularity');
|
||||
if (!Number.isInteger(granularity)) throw new Error('granularity is not an integer');
|
||||
if (start == null) throw new Error('missing start');
|
||||
start = checkValidRev(start);
|
||||
if (requestID == null) throw new Error('mising requestID');
|
||||
const end = start + (100 * granularity);
|
||||
const {padId, author: authorId} = sessioninfos[socket.id];
|
||||
const pad = await padManager.getPad(padId, null, authorId);
|
||||
const headRev = pad.getHeadRevisionNumber();
|
||||
if (start > headRev)
|
||||
start = headRev;
|
||||
const data = await getChangesetInfo(pad, start, end, granularity);
|
||||
data.requestID = requestID;
|
||||
socket.json.send({type: 'CHANGESET_REQ', data});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue