Skip to content

fix(OSQUERY-003): CU-86akhf8u2 genSudoersFile ignores unchecked substr/at() calls on possibly malformed sudoers lines - #76

Draft
flamingo[bot] wants to merge 1 commit into
masterfrom
ai-fix/osquery-003-8953f6db-39233833
Draft

flamingo[bot] wants to merge 1 commit into
masterfrom
ai-fix/osquery-003-8953f6db-39233833

Conversation

@flamingo

@flamingo flamingo Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Closes findings from rule OSQUERY-003 — genSudoersFile ignores unchecked substr/at() calls on possibly malformed sudoers lines.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟡 85 medium genSudoersFile ignores unchecked substr/at() calls on possibly malformed sudoers lines osquery/tables/system/posix/sudoers.cpp:118

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 39233833-f1d6-416e-93a7-71af15e3e968

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

ClickUp task: CU-86akhf8u2 Osquery review findings sweep (15 PRs)

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 What this fix changed, finding by finding

1 finding(s) fixed in this draft — 1 explained inline on the diff.

@@ -117,11 +117,16 @@ void genSudoersFile(const std::string& filename,

if (is_includedir) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔴 genSudoersFile ignores unchecked substr/at() calls on possibly malformed sudoers lines

In genSudoersFile (osquery/tables/system/posix/sudoers.cpp), the two rule_details.at(0) calls under the is_includedir and is_include branches are now guarded with !rule_details.empty() before indexing, and an explicit empty-string check (with a TLOG message and continue) was added right after each path-normalization block to avoid passing an empty string into listFilesInDirectory/recursive genSudoersFile calls. This removes the possibility of an uncaught std::out_of_range from .at(0) on a malformed/empty rule_details value while preserving existing control flow and style.

🤖 Prompt for AI agents
In osquery/tables/system/posix/sudoers.cpp around line 118, review and complete this code-review fix: genSudoersFile ignores unchecked substr/at() calls on possibly malformed sudoers lines.
What the draft fix changed: In genSudoersFile (osquery/tables/system/posix/sudoers.cpp), the two `rule_details.at(0)` calls under the `is_includedir` and `is_include` branches are now guarded with `!rule_details.empty()` before indexing, and an explicit empty-string check (with a TLOG message and `continue`) was added right after each path-normalization block to avoid passing an empty string into `listFilesInDirectory`/recursive `genSudoersFile` calls. This removes the possibility of an uncaught `std::out_of_range` from `.at(0)` on a malformed/empty rule_details value while preserving existing control flow and style.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(OSQUERY-003): genSudoersFile ignores unchecked substr/at() calls on possibly malformed sudoers lines fix(OSQUERY-003): CU-86akhf8u2 genSudoersFile ignores unchecked substr/at() calls on possibly malformed sudoers lines Sep 22, 2026
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.

0 participants