Skip to content

harden: found an unscoped `find( in compliance_hosts_controller.rb... - #619

Open
anupamme wants to merge 2 commits into
theforeman:masterfrom
anupamme:fix-repo-foreman-openscap-unscoped-find-compliance-hosts-controller
Open

harden: found an unscoped `find( in compliance_hosts_controller.rb...#619
anupamme wants to merge 2 commits into
theforeman:masterfrom
anupamme:fix-repo-foreman-openscap-unscoped-find-compliance-hosts-controller

Conversation

@anupamme

Copy link
Copy Markdown

Summary

Harden input handling in app/controllers/compliance_hosts_controller.rb (flagged by semgrep).

Vulnerability

Field Value
ID ruby.rails.security.brakeman.check-unscoped-find.check-unscoped-find
Severity HIGH
Scanner semgrep
Rule ruby.rails.security.brakeman.check-unscoped-find.check-unscoped-find
File app/controllers/compliance_hosts_controller.rb:3
Assessment Defensive hardening

Description: Found an unscoped find(...) with user-controllable input. If the ActiveRecord model being searched against is sensitive, this may lead to Insecure Direct Object Reference (IDOR) behavior and allow users to read arbitrary records. Scope the find to the current user, e.g. current_user.accounts.find(params[:id]).

Threat Model Context

This controller appears to be publicly accessible. This is a Node.js library - vulnerabilities affect downstream consumers who use this package.

Changes

  • app/controllers/compliance_hosts_controller.rb

Behavior Preservation

The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.


This patch removes an exploit primitive — a code pattern that, while not independently exploitable today, could be chained with other weaknesses by automated exploit-development tooling. Proactive removal of such primitives raises the bar against increasingly capable automated attack tools.


Automated security fix by OrbisAI Security

@adamruzicka adamruzicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the patch.

Instead of changing what we do in show, could we instead include the FindCommon concern and delegate the lookup to a find_resource before_action?

@anupamme

Copy link
Copy Markdown
Author

Review comments addressed. Pls review.

@adamruzicka

Copy link
Copy Markdown
Contributor

Looks reasonable, let's see what CI thinks.

On a more general note, this project uses redmine (https://projects.theforeman.org/projects/foreman_openscap) for issue tracking and commit messages have to be shaped like Fixes #<issue-id> - <description>.

@anupamme
anupamme force-pushed the fix-repo-foreman-openscap-unscoped-find-compliance-hosts-controller branch from 167ed61 to b2b8ed3 Compare August 17, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants