Conversation
…on` elements As explained in https://learn.microsoft.com/en-us/previous-versions/aspnet/ms178692(v=vs.100), it is possible to add `system.webServer` elements nested inside `location` elements in `Web.config`.
Contributor
There was a problem hiding this comment.
Pull Request Overview
Fixes the C# security query for missing X-Frame-Options headers to properly detect when these headers are configured within location elements in Web.config files, as supported by ASP.NET.
- Updated the query logic to check for X-Frame-Options headers in both direct
system.webServerelements and those nested insidelocationelements - Added comprehensive test coverage for the new
locationelement scenario
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
MissingXFrameOptions.ql |
Updated query logic to support detection of X-Frame-Options headers within location elements |
Web.config |
Test configuration demonstrating X-Frame-Options header configured within a location element |
MissingXFrameOptions.cs |
Test C# code with HTTP handler for testing the security query |
MissingXFrameOptions.qlref |
Query reference file for the test case |
options |
Test configuration options for the CodeQL extractor |
cs/web/missing-x-frame-options to also consider `locati…cs/web/missing-x-frame-options to also consider location elements
Contributor
michaelnebel
left a comment
There was a problem hiding this comment.
Thank you for doing this!
Maybe we should also run DCA before merging.
csharp/ql/src/Security Features/CWE-451/MissingXFrameOptions.ql
Outdated
Show resolved
Hide resolved
4c0391e to
316225b
Compare
csharp/ql/src/change-notes/2025-10-17-location-in-web-config.md
Outdated
Show resolved
Hide resolved
| import semmle.code.asp.WebConfig | ||
| import semmle.code.csharp.frameworks.system.Web | ||
|
|
||
| XmlElement getAWebConfigRoot(WebConfigXml webConfig) { |
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.
As explained in
https://learn.microsoft.com/en-us/previous-versions/aspnet/ms178692(v=vs.100),
it is possible to add
system.webServerelements nested insidelocationelements inWeb.config.