Repository navigation
[New Query - githubsecuritylab/cs/web/web-method-missing-access-control] - ASMX web methods that change data without an authorization check - #281
Draft
felickz wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.
…for [WebMethod] methods Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Active findings identify missed access-control alerts, false positives on methods that are not remotely callable, and unsafe remediation guidance that omits required account authorization.
4 open issues
Review effort: Balanced
| */ | ||
| class WebMethodActionMethod extends ActionMethod { | ||
| WebMethodActionMethod() { | ||
| this.getAnAttribute().getType() instanceof SystemWebServicesWebMethodAttributeClass |
| or | ||
| this.getName() | ||
| // separate camelCase words | ||
| .regexpReplaceAll("([a-z])([A-Z])", "$1_$2") |
Comment on lines
+30
to
+32
| attr.getType() | ||
| .getABaseType*() | ||
| .hasFullyQualifiedName(["System.Web.Mvc", "System.Web.Http"], "AuthorizeAttribute") |
Comment on lines
+54
to
+55
| The method is fixed by checking that the caller is authenticated (and, ideally, owns the debited | ||
| account): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The standard
cs/web/missing-function-level-access-controlquery only checks MVC controller actions and Web Forms event handlers. It never looks at[WebMethod]methods, which are ASMX operations and static page methods. This PR adds a query that reports those methods when they appear to change data and have no authorization check.Query (
csharp/src/security/CWE-862/)WebMethodActions.qll:WebMethodActionMethodis anActionMethodthat carriesSystem.Web.Services.WebMethodAttribute.isEdit()withtransfer,withdraw,deposit,updateandremove.WebMethodMissingAccessControl.ql:fromclause isWebMethodActionMethod, so nothing the standard query already reports is reported again.needsAuth,hasAuthViaCodeandhasAuthViaXml.hasAuthViaAttributewith a version that skipsSystem.Web.Mvc.AuthorizeAttribute,System.Web.Http.AuthorizeAttributeand their subclasses. Those are filters for the MVC and Web API pipelines and do not run for ASMX.@precision mediumand@security-severity 7.5, as in the standard query. CWE-285, CWE-284 and CWE-862, plus theexperimentaltag. The defaultcsharp.qlssuite selects it.WebMethodMissingAccessControl.qhelp.Changes from the draft in the issue
Authorizeattribute is treated like the MVC one: neither protects a web method.Web.configwas cut off. It is now complete, with<location path="ConfiguredService.asmx">denying?. That path is a prefix of the code-behind routeWebConfig/ConfiguredService.asmx.cs..expectedfile with BAD/GOOD comments instead of inline$ Alertmarkers, matching the other tests in this repository.Test (
csharp/test/security/CWE-862/WebMethodMissingAccessControl/)System.Webstubs inStubs.cs. The sharedSystem.Web.csstub has noWebService,HttpContext.Useror MVCAuthorizeAttribute.[Authorize], on the method or on the classApp_CodevariantWebConfig/folder that no<location>rule coversIsAuthenticatedorIsInRoleWeb.configruleGetLastUpdated[WebMethod]Known limitations
Adminclass is reported.build-mode: none, anIsInRolecall on an unresolvedIPrincipalis not recognized as a check.IsAuthenticatedstill is, through the%auth%name fallback.PrincipalPermission, are not counted as authorization.Follow-ups for the maintainer
githubsecuritylab/codeql-csharp-querieswhen cutting the release.