Skip to content
Access control Write-up Intermediate

Sudo: Authentication bypass when clock is reset

Sudo's timestamp file, which records recent authentication, could be reset to the epoch (1970-01-01) using 'sudo -k'. If a user could also set the system clock to the epoch, sudo would treat the timestamp as valid and allow running sudo commands without a password.

sudo.ws

Published on sudo.ws

When a user successfully authenticates with sudo, a time stamp file is updated to allow that user to continue running sudo without requiring a password for a preset time period (five minutes by default). The user’s time stamp file can be reset using sudo -k or removed altogether via sudo -K.

The author, on sudo.ws

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the timestamp file was reset to the epoch by 'sudo -k' and sudo did not treat an epoch timestamp as invalid, so when the system clock was also set to the epoch the timestamp appeared current.

Impact

An attacker with local access to an unlocked machine could run sudo commands without knowing the user's password, but only commands already permitted by the sudoers policy.

What the attacker needed

Local access to the machine; user has run sudo before; ability to change system clock

The fix

The bug was fixed in sudo 1.8.6p7 and 1.7.10p7 by ignoring a timestamp file set to the epoch.

How it was found

  1. Successfully authenticate with sudo at least once.
  2. Run 'sudo -k' to reset the timestamp file to the epoch.
  3. Set the system clock to the epoch (1970-01-01 01:00:00).
  4. Run a sudo command without being prompted for a password.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Sudo normally asks for your password the first time you use it, then remembers you for a few minutes by writing a timestamp file. This report shows that if that file is set to a very old date (the epoch, 1970) and the computer's clock is also set to that date, sudo thinks the timestamp is still valid and lets you run commands without asking for a password again.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.