Skip to content

Caddy-SSH vulnerable to Authorization Bypass due to incorrect usage of PAM library

High severity GitHub Reviewed Published Sep 23, 2022 in kadeessh/kadeessh • Updated Jan 8, 2023

Package

gomod github.com/mohammed90/caddy-ssh (Go)

Affected versions

= 0.0.1

Patched versions

None

Description

Not invoking a call to pam_acct_mgmt after a call to pam_authenticate to check the validity of a login can lead to an authorization bypass.

Impact

Exploitability

The attack can be carried over the network. A complex non-standard configuration or a specialized condition is required for the attack to be successfully conducted. The attacker also requires access to a users credentials, be it expired, for an attack to be successful. There is no user interaction required for successful execution. The attack can affect components outside the scope of the target module.

Impact

Using this attack vector, an attacker may access otherwise restricted parts of the system. The attack can be used to gain access to confidential files like passwords, login credentials and other secrets. Hence, it has a high impact on confidentiality. It may also be directly used to affect a change on a system resource. Hence has a medium to high impact on integrity. This attack may not be used to affect the availability of the system. Taking this account an appropriate CVSS v3.1 vector would be
AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:N

Root Cause Analysis

In this case, in the following PAM transaction, only a call to pam.Authenticate is used to login a user.

https://github.com/mohammed90/caddy-ssh/blob/1d980ceea6e67765daf19b5e644c7a0773fdaa13/internal/authentication/os/pam.go#L60

This implies that a user with expired credentials can still login.

The bug can be verified easily by creating a new user account, expiring it with chage -E0 <username> and then trying to log in with the expired credentials.

Patches

This can be fixed by invoking a call to pam.AcctMgmt after a successful call to pam.Authenticate

References

References

@mohammed90 mohammed90 published to kadeessh/kadeessh Sep 23, 2022
Published to the GitHub Advisory Database Sep 23, 2022
Reviewed Sep 23, 2022
Last updated Jan 8, 2023

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
High
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:N

Weaknesses

CVE ID

No known CVE

GHSA ID

GHSA-gmhj-xjfh-cf6m

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.