Skip to content

Commit

Permalink
Merge pull request #1671 from suraj-webkul/XSS
Browse files Browse the repository at this point in the history
Krayin CRM vulnerable to Cross Site Scripting (XSS) via the organizat…
  • Loading branch information
devansh-webkul authored Oct 9, 2024
2 parents 8eedf6c + 7a6289f commit 5a5b078
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## **v1.3.1 (9th of October 2024)** - *Release*

* Fix security issues.

## **v1.3.0 (21st of June 2024)** - *Release*

* #1251[upgrade] Upgraded the Laravel framework to version 10, incorporating the latest features and enhancements for improved performance, security, and developer experience and Installer package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function create()
return view('admin::contacts.organizations.create');
}


/**
* Store a newly created resource in storage.
*
Expand All @@ -54,7 +53,11 @@ public function store(AttributeForm $request)
{
Event::dispatch('contacts.organization.create.before');

$organization = $this->organizationRepository->create(request()->all());
$organization = $this->organizationRepository->create([
'name' => $request->input('name'),
'address' => $request->input('address'),
'entity_type' => $request->input('entity_type'),
]);

Event::dispatch('contacts.organization.create.after', $organization);

Expand Down Expand Up @@ -87,7 +90,11 @@ public function update(AttributeForm $request, $id)
{
Event::dispatch('contacts.organization.update.before', $id);

$organization = $this->organizationRepository->update(request()->all(), $id);
$organization = $this->organizationRepository->update([
'name' => $request->input('name'),
'address' => $request->input('address'),
'entity_type' => $request->input('entity_type'),
], $id);

Event::dispatch('contacts.organization.update.after', $organization);

Expand Down
27 changes: 27 additions & 0 deletions packages/Webkul/UI/src/DataGrid/Traits/ProvideCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public function sortOrFilterCollection($collection, $parseInfo)
public function formatCollection()
{
$this->collection->transform(function ($record) {
$record = $this->sanitizeRecord($record);

$this->transformRows($record);

$this->transformActions($record);
Expand Down Expand Up @@ -415,4 +417,29 @@ private function generateKeyFromActionTitle($title, $suffix)

return strtolower($validatedStrings) . $suffix;
}

/**
* Prepare all the setup for datagrid.
*/
protected function sanitizeRecord($record)
{
/**
* Convert stdClass to array.
*/
$tempRow = json_decode(json_encode($record), true);

foreach ($tempRow as $column => $value) {
if (! is_string($tempRow[$column])) {
continue;
}

if (is_array($value)) {
return $this->sanitizeRow($tempRow[$column]);
} else {
$record->{$column} = strip_tags($value);
}
}

return $record;
}
}

0 comments on commit 5a5b078

Please sign in to comment.