Skip to content

Improper Input Validation in simple_form

Critical severity GitHub Reviewed Published Sep 27, 2019 in heartcombo/simple_form • Updated Aug 28, 2023

Package

bundler simple_form (RubyGems)

Affected versions

< 5.0.0

Patched versions

5.0.0

Description

Incorrect Access Control in file_method? in lib/simple_form/form_builder.rb; a user-supplied string is invoked as a method call

Impact

For pages that build a form using user input, it is possible for an attacker to manipulate the input and send any method present in the form object. For example:

<%= simple_form_for @user do |f| %>
  <%= f.label @user_supplied_string %>
  ...
<% end %>

The string provided in the variable @user_supplied_string would be invoked as a method call inside the @user object (unless the string contains any of the following: password, time_zone, country, email, phone and url).

By manipulation that input, an attacker could do any of the following:

  • Code execution (call actions like #destroy)
  • Denial of Service (by executing a computation intensive method)
  • Information Disclosure (check the presence of methods, leak user information)

Patches

The problem was fixed in version 5.0. Although it's a major version, there should be no issues with upgrading for 4.x. The reason it was released in a major version is that the configuration SimpleForm.file_methods was deprecated in order to fix the problem.

Workarounds

The issue only happens with pages that build forms based on user-provided input. If your application doesn't do that, you're not affected.
A workaround is to explicitly pass which type you want for an input since the issue lies on Simple Form's automatically discovery of input types. This can be done using the as option, like the following:

<%= form.input :avatar, as: :file %>

References

[TDB]

For more information

If you have any questions or comments about this advisory:

References

@tegon tegon published to heartcombo/simple_form Sep 27, 2019
Published to the GitHub Advisory Database Sep 30, 2019
Reviewed Jun 16, 2020
Last updated Aug 28, 2023

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

EPSS score

0.750%
(81st percentile)

Weaknesses

CVE ID

CVE-2019-16676

GHSA ID

GHSA-r74q-gxcg-73hx

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.