Skip to content

search_id() lookup by login time vulnerable to time going backwards #28

Description

@andy-bower

Currently search_id() looks for the latest matching entry by login time:

char *sql = "SELECT ID FROM wtmp WHERE TTY = ? AND Logout IS NULL ORDER BY Login DESC LIMIT 1";

Isn't this vulnerable to if the system time has ever been later than now (sadly, it happens!) and then returning a wrong, 'earlier', record?

How about changing the ordering to descending order of row ID if sqlite3 guarantees this is always monotonically increasing? Perhaps that would even be more performant if sqlite3 backs the primary key with an index, which I imagine it does!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions