Skip to content

Commit 33d9a9b

Browse files
committed
Fix possible security issue in service register
1 parent 176e3b7 commit 33d9a9b

File tree

4 files changed

+74
-4
lines changed

4 files changed

+74
-4
lines changed

doc/10-Knowledge-Base.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ For this reason you will find a list of Icinga knowledge base entries below. Ent
1515
| [IWKB000005](knowledgebase/IWKB000005.md) | powershell.exe : Failed to start service 'Icinga PowerShell Service (icingapowershell)'. |
1616
| [IWKB000006](knowledgebase/IWKB000006.md) | The user you are running this command as does not have permission to access the Windows Update ComObject "Microsoft.Update.Session". |
1717
| [IWKB000007](knowledgebase/IWKB000007.md) | Icinga Director Self-Service API fails with errors. [Error]: The remote host for address "..." could not be resolved [Error]: Failed to connect to your Icinga Director at "...". Please try again. |
18+
| [IWKB000008](knowledgebase/IWKB000008.md) | The EventLog contains many `Perflib`, `PerfNet` and `PerfProc` errors/warnings with EventId `1008`, `2002` and `2004` |
19+
| [IWKB000009](knowledgebase/IWKB000009.md) | The remote Windows host has at least one service installed that uses an unquoted service path, which contains at least one whitespace. A local attacker can gain elevated privileges by inserting an executable file in the path of the affected service |

doc/31-Changelog.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ documentation before upgrading to a new release.
77

88
Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-framework/milestones?state=closed).
99

10-
## 1.5.0 (pending)
10+
## 1.4.2 (2021-07-09)
1111

12-
### Enhancements
12+
### Security Fixes
1313

14-
### Bugfixes
14+
* [#298](https://github.com/Icinga/icinga-powershell-framework/issues/298) Fixes possible security vulnerability on Icinga for Windows service registration, by not quoting the service path on registration
15+
16+
You can read more on this on the [Knowledge Base Entry](https://icinga.com/docs/icinga-for-windows/latest/doc/knowledgebase/IWKB000009/) with further details, on how to apply the fix and test if you are affected.
1517

1618
## 1.4.1 (2021-03-10)
1719

@@ -59,6 +61,14 @@ There are changes made to the pre-compiled configuration files and `Get-IcingaCh
5961
* [#204](https://github.com/Icinga/icinga-powershell-framework/pull/204) Adds experimental feature to forward checks executed by the Icinga Agent to an internal REST-Api, to reduce the performance impact on systems with lower resources available
6062
* [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Adds new experimental feature `Management Console` for better and easier management for Icinga for Windows and improved automation and deployed.
6163

64+
## 1.3.2 (2021-07-09)
65+
66+
### Security Fixes
67+
68+
* [#298](https://github.com/Icinga/icinga-powershell-framework/issues/298) Fixes possible security vulnerability on Icinga for Windows service registration, by not quoting the service path on registration
69+
70+
You can read more on this on the [Knowledge Base Entry](https://icinga.com/docs/icinga-for-windows/latest/doc/knowledgebase/IWKB000009/) with further details, on how to apply the fix and test if you are affected.
71+
6272
## 1.3.1 (2021-02-04)
6373

6474
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/12?closed=1)

doc/knowledgebase/IWKB000009.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Icinga Knowledge Base - IWKB000009
2+
3+
## Short Message
4+
5+
Security Scanner: The remote Windows host has at least one service installed that uses an unquoted service path, which contains at least one whitespace. A local attacker can gain elevated privileges by inserting an executable file in the path of the affected service
6+
7+
## Reason
8+
9+
The path pointing to the `icinga-service.exe` is not encapsulated inside double quotes `"` during creation. This might open a possible vulnerability and provide a possible attack vector for attackers gaining access to the machine. In worst case, attackers can place a binary file on the location of the path where the whitespace stops. This binary is then executed with the privileges the service is running with, which could cause a security issue.
10+
11+
You can read this [blogpost](http://www.ryanandjeffshow.com/blog/2013/04/05/the-microsoft-windows-unquoted-service-path-vulnerability/) by Jeff Liford to get a better idea on the problem.
12+
13+
## Solution
14+
15+
This is directly fixed within Icinga for Windows v1.3.2, 1.4.2, v1.5.2 and 1.6.0 during the service creation. If you created the service starting with one of these versions, you are not affected.
16+
17+
If not, please update your environment to a version which includes the fix and start a new PowerShell. Afterwards use this code snippet to re-create the service with all your configuration:
18+
19+
```powershell
20+
Use-Icinga;
21+
$IcingaService = Get-CimInstance Win32_Service `
22+
| Where-Object {
23+
$_.Name -eq 'icingapowershell'
24+
} `
25+
| Select-Object Name, StartName, PathName;
26+
27+
if ($null -ne $IcingaService) {
28+
$IfWUser = $IcingaService.StartName;
29+
$IfWPath = $IcingaService.PathName.SubString(0, $IcingaService.PathName.IndexOf(' "'));
30+
31+
if ($IfWPath[0] -eq '"' -And $IfWPath[-1] -eq '"') {
32+
return;
33+
}
34+
35+
Uninstall-IcingaFrameworkService;
36+
Install-IcingaFrameworkService -Path $IfWPath -User $IfWUser;
37+
}
38+
```
39+
40+
## Test Vulnerability
41+
42+
If you want to test if the above fix work or if you are affected by this problem, you can run this script:
43+
44+
```powershell
45+
$IcingaService = Get-CimInstance Win32_Service `
46+
| Where-Object {
47+
$_.Name -eq 'icingapowershell'
48+
} `
49+
| Select-Object Name, StartName, PathName;
50+
51+
$IfWPath = $IcingaService.PathName.SubString(0, $IcingaService.PathName.IndexOf(' "'));
52+
53+
if ($IfWPath.Contains('"')) {
54+
Write-Host -ForegroundColor Green 'Your service installation is secure';
55+
} else {
56+
Write-Host -ForegroundColor Red 'You are possibly affected by a whitespace service vulnerability';
57+
}
58+
```

lib/core/framework/Install-IcingaFrameworkService.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Install-IcingaFrameworkService()
6161
}
6262

6363
$Path = [string]::Format(
64-
'{0} \"{1}\"',
64+
'\"{0}\" \"{1}\"',
6565
$Path,
6666
(Get-IcingaPowerShellModuleFile)
6767
);

0 commit comments

Comments
 (0)