Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

The WACOA collector script had multiple KQL injection vulnerabilities allowing malicious JSON scope files or YAML definitions to execute arbitrary queries against Azure Resource Graph. Additionally, users encountered runtime errors when settings.json was missing the scriptVersion field.

Security Fixes

KQL Injection Prevention

  • Escape single quotes in subscription IDs, resource group names, and resource types before interpolating into KQL queries
  • Add validation functions: Test-SubscriptionId (GUID format), Test-ResourceGroupName (Azure naming rules), Test-ResourceType (Provider.Service/type format)
  • Reject invalid inputs at parse time rather than at query execution
# Before: Direct interpolation allowed injection
$scopeConditions += "(SubAccountId == '$($scope.SubscriptionId)')"

# After: Escaped to prevent injection
$escapedSubId = $scope.SubscriptionId -replace "'", "''"
$scopeConditions += "(SubAccountId == '$escapedSubId')"

Archive Extraction Path Traversal Protection

  • Extract to staging directory first
  • Validate no entries contain ../ or ..\ patterns
  • Reject malicious archives before copying to final destination

Bug Fixes

Empty CurrentVersion Parameter

  • Handle missing scriptVersion in settings.json with automatic default
  • Add [AllowEmptyString()] attribute and null check in Check-ScriptVersion
  • Auto-repair incomplete settings files

CSV Header Detection

  • Replace hardcoded Skip 11 with dynamic header line detection
  • Warn if no data found after parsing

User Input Normalization

  • Apply .Trim().ToLower() to all Yes/No prompts for consistent behavior

Operational Improvements

  • Add security warnings when downloading scripts from remote URLs
  • Change logging ErrorAction from SilentlyContinue to Continue to surface write failures
  • Add file size validation (minimum 100 bytes) for downloaded scripts
Original prompt

Review the WARA collector script


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 3, 2026 16:49
Co-authored-by: arthurclares <53261392+arthurclares@users.noreply.github.com>
Co-authored-by: arthurclares <53261392+arthurclares@users.noreply.github.com>
Co-authored-by: arthurclares <53261392+arthurclares@users.noreply.github.com>
…A collector

Co-authored-by: arthurclares <53261392+arthurclares@users.noreply.github.com>
Copilot AI changed the title [WIP] Review WARA collector script for improvements Fix critical KQL injection vulnerabilities and runtime errors in WACOA collector Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Review 👀 PR that is ready to be reviewed Skill: DevOps GitHub setup and automation Skill: Documentation Documentation updates Tool: FinOps guide Implementing FinOps guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants