Skip to content

Commit 91f99ed

Browse files
committed
model skip_forgery_protection calls in ActionController classes
1 parent fad7e94 commit 91f99ed

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ruby/ql/lib/codeql/ruby/frameworks/ActionController.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,21 @@ predicate controllerTemplateFile(ActionControllerControllerClass cls, ErbFile te
257257
)
258258
)
259259
}
260+
261+
/**
262+
* A call to either `skip_forgery_protection` or
263+
* `skip_before_action :verify_authenticity_token` to disable CSRF authenticity
264+
* token protection.
265+
*/
266+
class ActionControllerSkipForgeryProtectionCall extends CSRFProtectionSetting::Range {
267+
ActionControllerSkipForgeryProtectionCall() {
268+
exists(MethodCall call | call = this.asExpr().getExpr() |
269+
call.getMethodName() = "skip_forgery_protection"
270+
or
271+
call.getMethodName() = "skip_before_action" and
272+
call.getAnArgument().(SymbolLiteral).getValueText() = "verify_authenticity_token"
273+
)
274+
}
275+
276+
override boolean getVerificationSetting() { result = false }
277+
}

0 commit comments

Comments
 (0)