Skip to content

GH#3716: Fix CRITICAL security issues from PR #1359 review#4062

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/3716-security-fixes
Mar 10, 2026
Merged

GH#3716: Fix CRITICAL security issues from PR #1359 review#4062
marcusquinn merged 1 commit intomainfrom
bugfix/3716-security-fixes

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

Summary

Fixes three critical/high-severity issues identified by CodeRabbit and Gemini in PR #1359 review:

  1. SQL injection in batch.shmax_retries, concurrency, max_concurrency, and max_load_factor were interpolated directly into SQL INSERT statements without validation. Added regex validation (^[0-9]+$) at parse time, rejecting non-integer input before it reaches any SQL query.

  2. Input validation in cron.sh — The --interval parameter was used directly in cron/launchd commands without validation. Added positive integer validation. (Note: the GH_TOKEN exposure issue was already fixed in t1260.)

  3. Data loss in database.sh — The t148 migration INSERT...SELECT omitted the triage_result column, causing silent data loss when migrating databases that had the column. Added triage_result to both the INSERT column list and SELECT clause.

Files changed (3 of 5 cap)

  • .agents/scripts/supervisor-archived/batch.sh — numeric validation for 4 SQL-interpolated variables
  • .agents/scripts/supervisor-archived/cron.sh — interval validation
  • .agents/scripts/supervisor-archived/database.sh — triage_result preserved in t148 migration

Verification

  • ShellCheck: zero violations on all 3 files
  • All validation uses POSIX regex ^[0-9]+$ — rejects any non-digit characters including SQL injection payloads

Closes #3716

…iage_result in migration (GH#3716)

- batch.sh: validate max_retries, concurrency, max_concurrency, max_load_factor
  as integers before embedding in SQL INSERT statements (SQL injection prevention)
- cron.sh: validate --interval is a positive integer before use in cron commands
- database.sh: include triage_result column in t148 migration INSERT...SELECT
  to prevent data loss when migrating from schemas that have the column

Closes #3716
@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 396 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Tue Mar 10 10:17:26 UTC 2026: Code review monitoring started
Tue Mar 10 10:17:26 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 396

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 396
  • VULNERABILITIES: 0

Generated on: Tue Mar 10 10:17:29 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 10, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c43f38e-8c7a-4f2e-9959-1eed32f33497

📥 Commits

Reviewing files that changed from the base of the PR and between e877229 and 0972f44.

📒 Files selected for processing (3)
  • .agents/scripts/supervisor-archived/batch.sh
  • .agents/scripts/supervisor-archived/cron.sh
  • .agents/scripts/supervisor-archived/database.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/3716-security-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@marcusquinn marcusquinn merged commit 7aa7b8c into main Mar 10, 2026
19 checks passed
@marcusquinn marcusquinn deleted the bugfix/3716-security-fixes branch March 10, 2026 10:27
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical security and data integrity issues identified in a previous review. It introduces robust input validation for several parameters in shell scripts to prevent SQL injection and ensures that a database migration correctly preserves all data, specifically the triage_result column, thereby enhancing the overall reliability and security of the system.

Highlights

  • SQL Injection Prevention: Implemented numeric validation for max_retries, concurrency, max_concurrency, and max_load_factor parameters in batch.sh to prevent SQL injection vulnerabilities.
  • Input Validation for Cron Interval: Added positive integer validation for the --interval parameter in cron.sh to ensure safe usage in cron/launchd commands.
  • Data Integrity in Database Migration: Corrected the t148 database migration in database.sh to properly include the triage_result column during INSERT...SELECT operations, preventing silent data loss.
Changelog
  • .agents/scripts/supervisor-archived/batch.sh
    • Added numeric validation for max_retries, concurrency, max_concurrency, and max_load_factor parameters.
  • .agents/scripts/supervisor-archived/cron.sh
    • Implemented positive integer validation for the --interval parameter.
  • .agents/scripts/supervisor-archived/database.sh
    • Updated the t148 migration to include the triage_result column in the INSERT...SELECT statement.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses several critical security vulnerabilities by introducing input validation for shell scripts and correcting a data migration to prevent data loss. The changes are well-targeted and correctly implemented. My feedback includes suggestions to simplify and strengthen the validation logic for positive integers in batch.sh and cron.sh, aligning with best practices for defense-in-depth against potential injection attacks.

Comment on lines +249 to +252
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--concurrency must be a positive integer, got: $2"
return 1
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To enhance defense-in-depth against potential injection attacks when parsing numeric data from untrusted sources, it's crucial to validate numeric fields. You can simplify this positive integer validation by using a single regular expression that excludes zero. This makes the check more concise, readable, and robust.

Suggested change
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--concurrency must be a positive integer, got: $2"
return 1
fi
if ! [[ "$2" =~ ^[1-9][0-9]*$ ]]; then
log_error "--concurrency must be a positive integer, got: $2"
return 1
fi
References
  1. When parsing delimited data from an untrusted source in a shell script, validate numeric fields before using them in calculations. This provides defense-in-depth against injection attacks that could result from delimiter shifting caused by malicious data.

Comment on lines +38 to +41
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--interval must be a positive integer (minutes), got: $2"
return 1
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To enhance defense-in-depth against potential injection attacks when parsing numeric data from untrusted sources, it's crucial to validate numeric fields. Similar to the validation for --concurrency, you can simplify this positive integer check by using a single regular expression that matches numbers starting from 1. This improves consistency, makes the validation logic more direct, and enhances robustness.

Suggested change
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--interval must be a positive integer (minutes), got: $2"
return 1
fi
if ! [[ "$2" =~ ^[1-9][0-9]*$ ]]; then
log_error "--interval must be a positive integer (minutes), got: $2"
return 1
fi
References
  1. When parsing delimited data from an untrusted source in a shell script, validate numeric fields before using them in calculations. This provides defense-in-depth against injection attacks that could result from delimiter shifting caused by malicious data.

alex-solovyev added a commit that referenced this pull request Mar 11, 2026
Replace two-part positive integer check (^[0-9]+$ then -eq 0) with
single regex ^[1-9][0-9]*$ that inherently excludes zero. More concise,
readable, and robust against injection per PR #4062 review feedback.

Closes #4077
alex-solovyev added a commit that referenced this pull request Mar 11, 2026
Replace two-part positive integer check (^[0-9]+$ + -eq 0) with single
regex ^[1-9][0-9]*$ that inherently rejects zero and non-numeric input.

Addresses PR #4062 review feedback for defense-in-depth consistency.
alex-solovyev added a commit that referenced this pull request Mar 11, 2026
Replace two-part positive integer check (^[0-9]+$ then -eq 0) with
single regex ^[1-9][0-9]*$ that inherently excludes zero. More concise,
readable, and robust against injection per PR #4062 review feedback.

Closes #4077
alex-solovyev added a commit that referenced this pull request Mar 11, 2026
Replace two-part positive integer check (^[0-9]+$ + -eq 0) with single
regex ^[1-9][0-9]*$ that inherently rejects zero and non-numeric input.

Addresses PR #4062 review feedback for defense-in-depth consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t1694: chore: merge root VERIFY.md into todo/VERIFY.md

1 participant