Security audit for Rails application - OWASP checks, vulnerability detection
Performs comprehensive security audit on Rails apps checking for SQL injection, XSS, mass assignment, and other OWASP vulnerabilities.
/plugin marketplace add bastos/rails-plugin/plugin install bastos-ruby-on-rails@bastos/rails-pluginfile-or-scopeSecurity audit request: $ARGUMENTS
Scope: $ARGUMENTS (or entire application if empty)
Perform comprehensive security audit checking for:
Check for:
where clausesfind_by_sql with user inputorder with user inputPatterns to find:
# DANGEROUS
where("name = '#{params[:name]}'")
find_by_sql("SELECT * FROM users WHERE id = #{params[:id]}")
order(params[:sort])
# SAFE
where(name: params[:name])
where("name = ?", params[:name])
order(Arel.sql(sanitize_sql(sort_column)))
Check for:
html_safe on user inputraw() with untrusted contentsanitize() in viewsPatterns to find:
<!-- DANGEROUS -->
<%= raw(user_content) %>
<%= params[:content].html_safe %>
<!-- SAFE -->
<%= sanitize(user_content) %>
<%= user_content %> <!-- Auto-escaped -->
Check for:
permit in strong parameterspermit (especially admin flags)permit! usagePatterns:
# DANGEROUS
params.permit!
params.require(:user).permit(:role, :admin)
# SAFE
params.require(:user).permit(:name, :email)
Check for:
Check for:
# DANGEROUS
def show
@article = Article.find(params[:id])
end
# SAFE
def show
@article = current_user.articles.find(params[:id])
end
Check for:
Check for:
skip_forgery_protection usageCheck for:
Check for:
Run:
bundle audit check --update
Output format:
For each finding:
Summary at end:
Search the specified files (or all app/ and config/ files) and report all security issues found.