Skip to content

Commit 0f25852

Browse files
legoktmjenkins-bot
authored and
jenkins-bot
committed
Require CSRF token for action=scribunto-console
This is basically unexploitable, given that Scribunto sessions are "extremely ephemeral", protected by a 31-bit non-cryptographically random token and generally contain very little useful data. But, requiring a CSRF token is a best practice and since this module is internal and only used in one place, it's also unlikely to break anything. Because it needs a token, the module is POST-only now too. Bug: T212071 Change-Id: I7fb6b4f856ee6194eb37c26e14f178fea6c0a3f6
1 parent 5f007a0 commit 0f25852

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

includes/ApiScribuntoConsole.php

+4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ protected function newSession() {
145145
];
146146
}
147147

148+
public function needsToken() {
149+
return 'csrf';
150+
}
151+
148152
public function isInternal() {
149153
return true;
150154
}

modules/ext.scribunto.edit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
api = new mw.Api();
281281
setPending();
282282

283-
api.post( params )
283+
api.postWithToken( 'csrf', params )
284284
.done( function ( result ) {
285285
if ( result.sessionIsNew === '' && !sentContent ) {
286286
// Session was lost. Resend query, with content

0 commit comments

Comments
 (0)