Skip to content

new qos_clock crate and boot-time kvm-clock validation#668

Draft
emostov wants to merge 1 commit into
mainfrom
zeke/wall-clock
Draft

new qos_clock crate and boot-time kvm-clock validation#668
emostov wants to merge 1 commit into
mainfrom
zeke/wall-clock

Conversation

@emostov

@emostov emostov commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary & Motivation (Problem vs. Solution)

This is meant to demonstrate how we could ensure we are using the kvm-clock.
This article discusses why the KVM clock https://blog.trailofbits.com/2024/09/24/notes-on-aws-nitro-enclaves-attack-surface/#time

Specifically

  • Ensure that current_clocksource is set to kvm-clock in the enclave’s kernel configuration; consider even adding an application-level runtime check for the clock (in case something goes wrong during enclave bootstrapping and it ends up with a different clock source).
  • Enable the Precision Time Protocol for better clock synchronization between the enclave and the hypervisor. It’s like the Network Time Protocol (NTP) but works over a hardware connection. It should be more secure (as it has a smaller attack surface) and easier to set up than the NTP.
  • For security-critical functionalities (like replay protections) use Unix time. Be careful with UTC and time zones, as daylight saving time and leap seconds may “move time backwards.”

Note this does not cover configuring PTP synchronization. This must be done on the parent ec2 instance

How I Tested These Changes

Pre merge check list

  • Call out updates and breaking changes via conventional commits
  • Communicate verification flow breaking changes especially thoroughly. If any of the following answers are no, then this is a verification flow breaking change:
    • Can enclaves in a previous QOS version still key forward to this new version?
    • Can previous versions of QOS verify attestations from this new version?
    • Can manifests generated by a previous version still be parsed by this one?
    • Can previous approvals still be verified against a manifest (i.e. is this a non-breaking change to the manifest signing payload)?
    • Can a previous version of QOS still perform a boot standard on an enclave of this version?

@emostov emostov requested review from a team as code owners April 14, 2026 21:47
Comment thread src/qos_clock/src/lib.rs
}

/// Source of Unix wall-clock time for expiry and freshness checks.
pub trait WallClock: Send + Sync {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realistically we could get around needing a trait and just use SystemTime::now().duration_since(SystemTime::UNIX_EPOCH). But trait might be useful for testing when we want to control time

@emostov emostov changed the title DEMO: new qos_clock crate and boot-time kvm-clock validation new qos_clock crate and boot-time kvm-clock validation Apr 14, 2026
@emostov emostov marked this pull request as draft April 14, 2026 22:04
Comment thread src/qos_clock/src/lib.rs
self.unix_time_millis()?
.checked_div(1_000)
.ok_or(WallClockError::TimeConversionFailed)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default implementation for SystemTime is inefficient... it's already a u64
https://doc.rust-lang.org/stable/src/core/time.rs.html#506

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.

2 participants