You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[New Query - githubsecuritylab/cs/web/web-method-missing-access-control] - ASMX web methods that change data without an authorization check - #281
The standard cs/web/missing-function-level-access-control query 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.
WebMethodActions.qll:WebMethodActionMethod is an ActionMethod that carries System.Web.Services.WebMethodAttribute.
It extends isEdit() with transfer, withdraw, deposit, update and remove.
These words are matched only as whole camelCase words and only against the method name.
WebMethodMissingAccessControl.ql:
The from clause is WebMethodActionMethod, so nothing the standard query already reports is reported again.
It reuses the standard needsAuth, hasAuthViaCode and hasAuthViaXml.
It replaces hasAuthViaAttribute with a version that skips System.Web.Mvc.AuthorizeAttribute, System.Web.Http.AuthorizeAttribute and their subclasses. Those are filters for the MVC and Web API pipelines and do not run for ASMX.
Metadata:@precision medium and @security-severity 7.5, as in the standard query. CWE-285, CWE-284 and CWE-862, plus the experimental tag. The default csharp.qls suite selects it.
Query help:WebMethodMissingAccessControl.qhelp.
Changes from the draft in the issue
The query has its own id, reports only web methods, and its message is "This web method is missing an authorization check."
The Web API Authorize attribute is treated like the MVC one: neither protects a web method.
The draft's Web.config was cut off. It is now complete, with <location path="ConfiguredService.asmx"> denying ?. That path is a prefix of the code-behind route WebConfig/ConfiguredService.asmx.cs.
The test uses a plain .expected file with BAD/GOOD comments instead of inline $ Alert markers, matching the other tests in this repository.
Test (csharp/test/security/CWE-862/WebMethodMissingAccessControl/)
Uses local System.Web stubs in Stubs.cs. The shared System.Web.cs stub has no WebService, HttpContext.User or MVC AuthorizeAttribute.
Reported (9):
plain BAD methods
methods protected only by MVC or Web API [Authorize], on the method or on the class
a static page method
the App_Code variant
a service in the WebConfig/ folder that no <location> rule covers
Not reported:
a check with IsAuthenticated or IsInRole
a non-MVC auth attribute on the method or the class
the service covered by the Web.config rule
read-only methods, including GetLastUpdated
an empty method, and a method without [WebMethod]
The standard query reports nothing on this test database.
Known limitations
Detection by name: whether a method changes data is guessed from its name. The standard words also match the class name and the file path, so a read-only method in an Admin class is reported.
No build: with build-mode: none, an IsInRole call on an unresolved IPrincipal is not recognized as a check. IsAuthenticated still is, through the %auth% name fallback.
Attribute names: attributes without "auth" in their name, such as PrincipalPermission, are not counted as authorization.
Follow-ups for the maintainer
Add a true positive from a real project.
Bump the version of githubsecuritylab/codeql-csharp-queries when cutting the release.
felickz
changed the title
[WIP] Add query for ASMX web methods authorization check
[New Query - githubsecuritylab/cs/web/web-method-missing-access-control] - ASMX web methods that change data without an authorization check
Nov 26, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 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.
@copilot Please address the four open review findings:
Limit alerts to remotely callable web methods: require a public method, and a static one on a System.Web.UI.Page subclass. Add a private web method and an instance page method as non-alerts.
Names that begin with an initialism: also split the boundary between an initialism and the next word, so that ATMWithdraw and XMLUpdate match, and keep GetLastUpdated a non-alert.
Authorization filters that never run for ASMX: treat System.Web.Http.Filters.AuthorizationFilterAttribute and its subclasses like the MVC AuthorizeAttribute, and add a custom filter on a web method as an alert.
The query help example: the fixed example must also check that the caller may debit the selected account, not only that the caller is authenticated.
Rerun the test and the gates of your profile. The Build CodeQL Packs run on the current head is still in progress: check its result and fix any failure.
Addressed in 6fffe9e. The targeted test and profile gates passed with CodeQL 2.27.5. The original Build CodeQL Packs run is still in progress; its overall result is pending.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The query has two false-negative gaps: custom MVC authorization filters can incorrectly suppress alerts, and expression-bodied web methods are excluded from detection.
Custom MVC authorization filters can implement System.Web.Mvc.IAuthorizationFilter without inheriting AuthorizeAttribute (for example, CustomAuthorizationAttribute : FilterAttribute, IAuthorizationFilter). Such an attribute passes the %auth% check below but none of these exclusions, so applying it to an otherwise unprotected [WebMethod] suppresses the alert even though MVC never executes the filter for ASMX. Extend the exclusion to cover these MVC filters and add a regression case alongside the Web API filter cases.
This excludes expression-bodied web methods as well as empty methods. For a public [WebMethod] such as void UpdateEmail(string email) => SaveEmail(email);, getBody() returns an expression with no child statement, so the unauthenticated update is never reported. Accept an expression body alongside a nonempty statement body, and add an expression-bodied regression case.
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
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.