File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -515,10 +515,18 @@ function patchMatrixClientForRetry() {
515515let isMatrixClientPatchedForPrototypePollution = false ;
516516
517517export function jsonReviver < T = unknown > ( key : string , value : T ) : T | undefined {
518- if ( key === "__proto__" || key === "constructor" ) {
519- return undefined ;
520- } else {
521- return value ;
518+ switch ( key ) {
519+ case "__proto__" :
520+ case "constructor" :
521+ case "prototype" :
522+ case "toString" :
523+ case "valueOf" :
524+ case "hasOwnProperty" :
525+ case "__defineGetter__" :
526+ case "__defineSetter__" :
527+ return undefined ;
528+ default :
529+ return value ;
522530 }
523531}
524532
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
2121} from "@the-draupnir-project/matrix-basic-types" ;
2222import { Logger , Task } from "matrix-protection-suite" ;
2323import { SynapseHttpAntispam } from "./SynapseHTTPAntispam/SynapseHttpAntispam" ;
24+ import { jsonReviver } from "../utils" ;
2425
2526const log = new Logger ( "WebAPIs" ) ;
2627
@@ -41,7 +42,7 @@ export class WebAPIs {
4142 private readonly synapseHTTPAntispam : SynapseHttpAntispam | undefined
4243 ) {
4344 // Setup JSON parsing.
44- this . webController . use ( express . json ( ) ) ;
45+ this . webController . use ( express . json ( { reviver : jsonReviver } ) ) ;
4546 this . synapseHTTPAntispam ?. register ( this . webController ) ;
4647 }
4748
You can’t perform that action at this time.
0 commit comments