Skip to content

Group-based and account-based JIT MFA bypass on scp and sftp

Moderate
speed47 published GHSA-pr4q-w883-pf5x Nov 8, 2023

Package

The Bastion

Affected versions

3.0.0 to 3.14.0 included

Patched versions

3.14.15 and up

Description

Summary

SCP and SFTP plugins don't honor group-based and account-based JIT MFA

Details

Establishing a SCP/SFTP connection through The Bastion via a group or personal access where MFA is enforced does not ask for additional factor. This abnormal behavior only applies to per-group-based JIT MFA and JIT MFA on a per-account basis.

Other MFA setup types, such as Immediate MFA or JIT MFA on a per-plugin basis are not affected.

Normal SSH access (i.e. not SCP nor SFTP) is not affected.

How to reproduce for group-based JIT MFA

  • Create a group
  • Apply groupModify --mfa-required any to this group
  • Grant SSH access to someone via this group on a given IP
  • Grant scp download right (or sftp right) to the same person via this group on the same IP
  • This group should now force MFA for any connection of the person allowed through the group's rights set. This is the case for SSH, but not for SCP or SFTP as would be expected.

How to reproduce for account-based JIT MFA

  • Create an account
  • Apply accountModify --personal-egress-mfa-required any to this account
  • Grant a personal SSH access to this account on a given IP
  • Grant scp download right (or sftp right) to the same account via their personal access on the same IP
  • This account should now have forced MFA for any egress connection allowed through their personal rights set. This is the case for SSH, but not for SCP or SFTP as would be expected.

Impact for group-based JIT MFA

For an actor to be able to bypass MFA for scp/sftp to a given remote server, ALL the following conditions must apply:

  • The target server must be part of a group (and have the egress group's public key trusted in its authorized_keys file)
  • The group must have JIT MFA enabled on it (through groupModify --mfa-required any)
  • The actor must have an account on the bastion
  • The actor must be a member of the group (granted by the groups's gatekeepers)
  • scp and/or sftp must be globally enabled on the bastion (this is the default)
  • scp and/or sftp must be explicitly allowed to the given remote server through the group (granted by the groups's aclkeepers)

When all conditions above apply, the actor would be able to use scp or sftp on the target server without requiring to provide an additional factor where it should.

Impact for account-based JIT MFA

For an actor to be able to bypass MFA for scp/sftp to a given remote server, ALL the following conditions must apply:

  • The target server must be part of the actor's account personal accesses (and have the account's egress public key trusted in its authorized_keys file)
  • The account must have JIT MFA enabled on it (through accountModify --personal-egress-mfa-required any)
  • scp and/or sftp must be globally enabled on the bastion (this is the default)
  • scp and/or sftp must be explicitly allowed to the given remote server through this account's personal accesses (granted by either selfAddPersonalAccess or accountAddPersonalAccess)

When all conditions above apply, the actor would be able to use scp or sftp on the target server without requiring to provide an additional factor where it should.

Mitigation

If you don't use the per-group-based JIT MFA on any of your groups (through groupModify --mfa-required), and don't use the JIT MFA on a per-account basis (through accountModify --personal-egress-mfa-required), you don't need to mitigate the issue as you don't use the impacted feature (see above for impact details).

Otherwise, if you can't immediately upgrade to v3.14.15 or more recent, and you feel that the aforementioned impacts are important enough in your environment, you may choose to temporarily disable the scp and sftp plugins globally on the bastion, by setting "disabled": true in these plugins configuration files, which can be found in /etc/bastion/plugin.scp.conf and /etc/bastion/plugin.sftp.conf respectively. If these files don't exist, create them with the contents as { "disabled": true }. They should be readable by anyone but modifiable only by root (i.e. chmod 664; chown root:root)

Severity

Moderate

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
Low
Privileges required
High
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
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:L/PR:H/UI:R/S:C/C:L/I:L/A:N

CVE ID

CVE-2023-45140

Weaknesses

Credits