Security
Headlines
HeadlinesLatestCVEs

Headline

GHSA-86h2-2g4g-29qx: avo possible unsafe reflection / partial DoS vulnerability

Summary

The polymorphic field type stores the classes to operate on when updating a record with user input, and does not validate them in the back end. This can lead to unexpected behavior, remote code execution, or application crashes when viewing a manipulated record.

Details

After reviewing the polymorphic field implementation and performing some black box approaches, we identified a potential security issue related to the use of safe_constantize / constantize. This Rails functionality is capable of searching for classes within the Rails context and returning the class for further use. Because Avo does not validate user input when updating or creating a new polymorphic resource, it is possible to create database entries with completely different or invalid class names than the preselected ones. Avo assumes that the class specified by the user request is a valid one and attempts to work with it, which may result in dangerous behavior and code execution.

PoC

image In the test scenario we choose the demo app and the review resource which has a polymorphic reviewable field.

image Intercepting the request and switching the review[reviewable_type] from “Fish” to “File” which is a real class inside Rails

image Corrupting the database with unusable classes will cause a crash at the application while viewing the new record or the index view (partial DoS)

image Manual delete the corrupted resource in order to recover the applications functionality

image Of course it is possible to use other class names or namespaces. The local development environment displays the backend error message when visiting a corrupted record. Avo is trying to apply a scope to this class that does not exist.

image Specifying an invalid class name in the parameter will cause the application to crash again while trying constanize the provided string

Impact

The final exploitation of this vulnerability requires more time than is provided in this assessment, but initial testing of the post request shows the potential critical risk. The classes could be instantiated at any point in the code and this could also lead to code execution.

Recommendation

Avo should be configured to never trust user-supplied input, especially when defining classes for records. In this particular case, Avo can evaluate the options list given for the polymorphic field and only allow strings from that list. With this white-list approach, an attacker cannot supply unintended classes.

ghsa
#vulnerability#git#rce

Summary

The polymorphic field type stores the classes to operate on when updating a record with user input, and does not validate them in the back end. This can lead to unexpected behavior, remote code execution, or application crashes when viewing a manipulated record.

Details

After reviewing the polymorphic field implementation and performing some black box approaches, we identified a potential security issue related to the use of safe_constantize / constantize. This Rails functionality is capable of searching for classes within the Rails context and returning the class for further use. Because Avo does not validate user input when updating or creating a new polymorphic resource, it is possible to create database entries with completely different or invalid class names than the preselected ones. Avo assumes that the class specified by the user request is a valid one and attempts to work with it, which may result in dangerous behavior and code execution.

PoC

In the test scenario we choose the demo app and the review resource which has a polymorphic reviewable field.

Intercepting the request and switching the review[reviewable_type] from “Fish” to “File” which is a real class inside Rails

Corrupting the database with unusable classes will cause a crash at the application while viewing the new record or the index view (partial DoS)

Manual delete the corrupted resource in order to recover the applications functionality

Of course it is possible to use other class names or namespaces. The local development environment displays the backend error message when visiting a corrupted record. Avo is trying to apply a scope to this class that does not exist.

Specifying an invalid class name in the parameter will cause the application to crash again while trying constanize the provided string

Impact

The final exploitation of this vulnerability requires more time than is provided in this assessment, but initial testing of the post request shows the potential critical risk. The classes could be instantiated at any point in the code and this could also lead to code execution.

Recommendation

Avo should be configured to never trust user-supplied input, especially when defining classes for records. In this particular case, Avo can evaluate the options list given for the polymorphic field and only allow strings from that list. With this white-list approach, an attacker cannot supply unintended classes.

References

  • GHSA-86h2-2g4g-29qx
  • https://nvd.nist.gov/vuln/detail/CVE-2023-34102
  • avo-hq/avo@ec11788
  • https://github.com/avo-hq/avo/releases/tag/v2.33.3

Related news

CVE-2023-34102: Merge pull request from GHSA-86h2-2g4g-29qx · avo-hq/avo@ec11788

Avo is an open source ruby on rails admin panel creation framework. The polymorphic field type stores the classes to operate on when updating a record with user input, and does not validate them in the back end. This can lead to unexpected behavior, remote code execution, or application crashes when viewing a manipulated record. This issue has been addressed in commit `ec117882d` which is expected to be included in subsequent releases. Users are advised to limit access to untrusted users until a new release is made.