Skip to content

Commit

Permalink
Avoid leakage of state.check_commandline to restricted users
Browse files Browse the repository at this point in the history
Users who do not have permission to see the object's `Source` tab, must be
restricted from accessing the object's `state.check_commandline` column.
  • Loading branch information
raviks789 committed Jun 21, 2023
1 parent 3628e97 commit 487de85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/Icingadb/Common/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ public function isMatchedOn(string $queryString, Model $object): bool
*/
public function applyRestrictions(Query $query)
{
// In case the user does not have permission to see the object's `Source` tab, then the user must be restricted
// from accessing the executed command for the object.
if (
($query->getModel()->getTableName() === 'host' || $query->getModel()->getTableName() === 'service')
&& ! $this->getAuth()->hasPermission('icingadb/object/show-source')
) {
$query->withoutColumns(['state.check_commandline']);
}

if ($this->getAuth()->getUser()->isUnrestricted()) {
return;
}
Expand Down
7 changes: 7 additions & 0 deletions library/Icingadb/Web/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public function createColumnControl(Query $query, ViewModeSwitcher $viewModeSwit
$columns = [];
foreach (explode(',', $columnsDef) as $column) {
if ($column = trim($column)) {
if (
array_slice(explode('.', $column), -1)[0] === 'check_commandline'
&& ! $this->hasPermission('icingadb/object/show-source')
) {
continue;
}

$columns[] = $column;
}
}
Expand Down

0 comments on commit 487de85

Please sign in to comment.