Skip to content

Commit 7e1c374

Browse files
committed
feat(security): add sessionId length limit
1 parent a53a90c commit 7e1c374

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

server/server.ts

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ app.use(bodyParser.urlencoded({ extended: true }))
1515

1616
app.use((req, res, next) => {
1717
if (req.body && req.body.sessionId) {
18+
if (req.body.sessionId.length > 300)
19+
return res.status(403).send({
20+
message: "SessionId length is too long",
21+
code: Errors.SessionIdTooLong,
22+
})
1823
if (req.body.sessionId in sessionCounter) next()
1924
else {
2025
if (Object.keys(sessionCounter).length > 20)

src/errors.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export enum Errors {
44
InvalidCounterValue,
55
FailedTokenVerify,
66
MissingRequestToken,
7+
SessionIdTooLong,
78
}

0 commit comments

Comments
 (0)