Vulnerability - Cross-site scripting on the listing data
Overview
Information disclosure date
2020/03/25
Target version
Under v3.1.6
Other
- There are currently no damage reports for this vulnerability.
Vulnerability content
Background of discovery
Discovered at the time of renovation by the developer.
Occurrence condition
The system administrator must enter the script in the following input contents.
- "Custom table display name" of custom table
- "Workflow display name" of the workflow
- "Workflow status name" of the workflow
- "User name" of user data
In this case, it occurs by displaying the following page.
- Custom view list screen
- Workflow list screen
- Notification list screen
- Usage log screen
Cause
- When the column of the list screen is displayed, the screen is displayed by the function "display". Since this may be displayed in HTML, it is not escaped.
php
///// CustomColumnController Custom column list screen HTML display of unique column check boxes
$grid->column('unique', exmtrans("custom_column.options.unique"))->sortable()->display(function ($val) {
return getTrueMark($val); // return : <i class="fa fa-check"></i>
});- Therefore, when displaying normal text, escape measures are required.
php
///// CustomColumnController Custom column list screen Display column type
$grid->column('column_type', exmtrans("custom_column.column_type"))->sortable()->display(function ($val) {
// Function to escape esc_html
return esc_html(array_get(ColumnType::transArray("custom_column.column_type_options"), $val));
});- However, there were some points where the escape procedure was not performed.
php
///// CustomViewController Custom view list screen Display table name
$grid->column('table_view_name', exmtrans("custom_table.table_view_name"))
->display(function () {
return $this->custom_table->table_view_name;
});- Therefore, cross-site scripting will occur if the script is intentionally entered in the elements described in "Occurrence conditions".
How to respond
Please do one of the following:
(Recommend)Update the Exment version to v3.1.7 or higher.
If you can not update due to some reason, please correct the following files.
php
///// vendor/exceedone/exment/src/Controller/CustomViewController.php
// In grid function.
$grid->column('table_name', exmtrans("custom_table.table_name"))
->display(function () {
return esc_html($this->custom_table->table_name); //Modify
});
$grid->column('table_view_name', exmtrans("custom_table.table_view_name"))
->display(function () {
return esc_html($this->custom_table->table_view_name); //Modify
});
// vendor/exceedone/exment/src/Controller/NotifyController.php
// In grid function.
$grid->column('custom_table_id', exmtrans("notify.notify_target"))->sortable()->display(function ($val) {
$custom_table = CustomTable::getEloquent($val);
if (isset($custom_table)) {
return esc_html($custom_table->table_view_name) ?? null; // Modify
}
if (isset($this->workflow_id)) {
return esc_html(Workflow::getEloquent($this->workflow_id)->workflow_view_name); // Modify
}
return null;
});
// vendor/exceedone/exment/src/Controller/WorkflowController.php
// In grid function.
$grid->column('workflow_tables', exmtrans("custom_table.table"))->display(function ($v) {
if (is_null($custom_table = $this->getDesignatedTable())) {
return null;
}
return esc_html($custom_table->table_view_name); // Modify
});
$grid->column('workflow_statuses', exmtrans("workflow.status_name"))->display(function ($value) {
return esc_html($this->getStatusesString()); //Modify
});
// vendor/exceedone/exment/src/Controller/LogController.php
// In grid function.
$grid->column('user.user_name', exmtrans('operation_log.user_name'))->display(function ($foo) {
return esc_html($this->user ? $this->user->user_name : null); // Modify
});Future recurrence prevention method
- Add a new function "displayEscape" that is displayed after escaping when displaying the columns on the list screen, and display "displayEscape" at the time of normal value display, only when it is necessary to display it in HTML. I will use it.
php
///// CustomViewController Custom view list screen Display table name
$grid->column('table_view_name', exmtrans("custom_table.table_view_name"))
->displayEscape(function () {
return $this->custom_table->table_view_name;
});