Skip to content

fix: wait a second before verify writes its test event - #89

Merged
spydisec merged 1 commit into
mainfrom
fix/verify-canary-clock
Nov 11, 2026
Merged

spydisec merged 1 commit into
mainfrom
fix/verify-canary-clock

Conversation

@spydisec

Copy link
Copy Markdown
Owner

Summary: verify.sh could miss its own test event when it started just after a second boundary. An install then rolled back although the rules worked. Fixes #86.

Cause

Verify took the start time with date, wrote the canary file right away, and searched with ausearch -ts <start>. The kernel stamps an audit event with a clock that runs a few milliseconds behind the one date reads. So an event written right after the start time can carry the second before it, and ausearch skips it.

Measured on Rocky Linux 10.2 with 4000 writes: the event time was earlier than the date taken before the write every time, by up to 2.3 ms, and 4 events were in the earlier second. The failed CI job from #86 fits, because its test event was stamped at .998 of a second.

The explanation in the issue, that auditd held the records in memory, was wrong.

Fix

  • Verify waits one second between the start time and the write, so the event is always after the start time. Verify takes one second longer.
  • The date and the time now come from one date call. With two calls they could be from two sides of midnight.

Tested

  • A new bats test checks that the wait comes before the write. It failed before the fix.
  • The fixed verify.sh passed 25 runs in a row on the Rocky VM.

verify.sh took the start time with date, wrote the canary file right away,
and searched for the event with ausearch -ts <start>. The kernel stamps an
audit event with a clock that runs a few ms behind the one date reads. When
the start time fell just after a second boundary, the event carried the second
before it, ausearch skipped it, and verify failed after 10 seconds. An install
then rolled back although the rules worked.

Measured on Rocky Linux 10.2: in 4000 writes the event time was earlier than
the date taken before the write every time, by up to 2.3 ms, and 4 events were
in the earlier second.

verify.sh now waits one second between the start time and the write. It also
takes the date and the time with one date call, so they can't be from two
sides of midnight.

Fixes #86

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 85b28e68-63eb-4597-a70e-dab3e5acf060
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@spydisec
spydisec merged commit ab1254d into main Nov 11, 2026
30 checks passed
@spydisec
spydisec deleted the fix/verify-canary-clock branch November 11, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

verify: the test event check can fail on a quiet host

1 participant