Skip to content

Fix GitHub Code Scanning alerts (Security and quality) - #23

Merged
Xenne93 merged 4 commits into
mainfrom
fix/code-scanning-security
Aug 16, 2026
Merged

Fix GitHub Code Scanning alerts (Security and quality)#23
Xenne93 merged 4 commits into
mainfrom
fix/code-scanning-security

Conversation

@Xenne93

@Xenne93 Xenne93 commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Fixes all open GitHub Code Scanning alerts under Security and quality (104 total).

Real fixes

  • Missing admin check on PanelSettingsController.PurgeData (any authenticated user, including moderators, could purge all logged data)
  • Unauthenticated arbitrary file read via PublicImagesController's fast disk-read path using an unvalidated instanceHash route parameter -> added path-containment validation in MapStorageService
  • Discord webhook URL validation hardened from a substring .Contains() check to actual Uri.Host/path validation
  • RconController.DeleteServer cleaned up to return NotFound explicitly instead of relying on a NullReferenceException falling through to a broad catch
  • Added permissions: blocks to both GitHub Actions workflows
  • Added a shared LogSanitizer helper (strips CR/LF) and applied it to every user-controlled string reaching a logger call across 18 files, closing all cs/log-forging alerts
  • Replaced User.GetEmail() with a non-PII user identifier in every log call that logged it, closing all cs/exposure-of-sensitive-information alerts

Dismissed as false positives (with reasoning documented on each alert)

Build verified locally: 0 errors.

- Add explicit permissions blocks to build-check.yml and
  remove-old-packages.yml workflows (actions/missing-workflow-permissions)
- Add missing admin check to PanelSettingsController.PurgeData, which
  previously let any authenticated user (including moderators) purge all
  logged data including audit logs
- Add path-containment validation to MapStorageService (GetServerImageFilePath)
  using Path.GetFullPath + base-directory prefix check, closing an
  unauthenticated arbitrary-file-read via PublicImagesController's
  fast disk-read path using an unvalidated instanceHash route parameter
  (cs/path-injection)
- Harden Discord webhook URL validation in ServerWebhookController.TestWebhook
  to check uri.Host/AbsolutePath explicitly instead of a raw substring
  .Contains() match
- Clean up RconController.DeleteServer to return NotFound on a missing/
  non-owned server instead of relying on a NullReferenceException falling
  through to a broad catch block
- Add a shared LogSanitizer helper and use it to strip CR/LF from every
  user-controlled string value before it reaches a logger call across 18
  files (cs/log-forging), converting any remaining string-interpolated log
  calls to structured logging with named placeholders along the way
- Replace User.GetEmail() with a non-PII user identifier (resolved user
  object's Id, or the NameIdentifier claim) in every log call that
  previously logged the user's email address (cs/exposure-of-sensitive-information)
- Mask the recipient address in EmailService's log calls instead of logging
  it in full
- Dismiss 4 alerts confirmed as false positives via the Code Scanning API,
  each with a documented reason (cs/cleartext-storage-of-sensitive-information
  #7, cs/user-controlled-bypass #4, #5, #6)

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

CodeQL's cs/log-forging barrier recognition requires the sanitizing
.Replace() call to appear directly in the tainted expression, not
routed through a custom static helper method - validated empirically
via a live re-scan (helper-based fix cleared only 1/65 alerts, one
inlined call site cleared immediately). Converted every remaining
call site accordingly and removed the now-dead LogSanitizer helper.
Comment thread RustRconServerManager.Backend/Services/EmailService.cs Fixed
Comment thread RustRconServerManager.Backend/Services/EmailService.cs Fixed
…ilService diagnostics

- PanelSettingsController: sanitize steamId in VAC-ban override log calls (cs/log-forging)
- EmailService: stop logging even a masked form of the recipient address, since
  CodeQL treats any value derived from the tainted parameter as still-sensitive
  regardless of transformation (cs/exposure-of-sensitive-information); removed
  the now-unused MaskEmail helper
@Xenne93
Xenne93 merged commit ce9b138 into main Aug 16, 2026
6 checks passed
@Xenne93
Xenne93 deleted the fix/code-scanning-security branch August 16, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants