Skip to content

Commit 5a5b078

Browse files
Merge pull request #1671 from suraj-webkul/XSS
Krayin CRM vulnerable to Cross Site Scripting (XSS) via the organizat…
2 parents 8eedf6c + 7a6289f commit 5a5b078

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## **v1.3.1 (9th of October 2024)** - *Release*
2+
3+
* Fix security issues.
4+
15
## **v1.3.0 (21st of June 2024)** - *Release*
26

37
* #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.

packages/Webkul/Admin/src/Http/Controllers/Contact/OrganizationController.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function create()
4343
return view('admin::contacts.organizations.create');
4444
}
4545

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

57-
$organization = $this->organizationRepository->create(request()->all());
56+
$organization = $this->organizationRepository->create([
57+
'name' => $request->input('name'),
58+
'address' => $request->input('address'),
59+
'entity_type' => $request->input('entity_type'),
60+
]);
5861

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

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

90-
$organization = $this->organizationRepository->update(request()->all(), $id);
93+
$organization = $this->organizationRepository->update([
94+
'name' => $request->input('name'),
95+
'address' => $request->input('address'),
96+
'entity_type' => $request->input('entity_type'),
97+
], $id);
9198

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

packages/Webkul/UI/src/DataGrid/Traits/ProvideCollection.php

+27
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public function sortOrFilterCollection($collection, $parseInfo)
8989
public function formatCollection()
9090
{
9191
$this->collection->transform(function ($record) {
92+
$record = $this->sanitizeRecord($record);
93+
9294
$this->transformRows($record);
9395

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

416418
return strtolower($validatedStrings) . $suffix;
417419
}
420+
421+
/**
422+
* Prepare all the setup for datagrid.
423+
*/
424+
protected function sanitizeRecord($record)
425+
{
426+
/**
427+
* Convert stdClass to array.
428+
*/
429+
$tempRow = json_decode(json_encode($record), true);
430+
431+
foreach ($tempRow as $column => $value) {
432+
if (! is_string($tempRow[$column])) {
433+
continue;
434+
}
435+
436+
if (is_array($value)) {
437+
return $this->sanitizeRow($tempRow[$column]);
438+
} else {
439+
$record->{$column} = strip_tags($value);
440+
}
441+
}
442+
443+
return $record;
444+
}
418445
}

0 commit comments

Comments
 (0)