Actions

Dev/TimeSync

From Whonix

< Dev


Basic Knowledge[edit]

Introduction[edit]

The Post Install Advice is part of this design, therefore read Network Time Syncing first. Also read Network Time Synchronization as well.

Virtualizers Time Synchronization Features[edit]

VirtualBox Time Synchronization Features[edit]

For understanding Whonix ™ Time Synchronization Mechanism, it is required to know VirtualBox's time synchronization features:

  • VirtualBox uses the host's time if it needs to correct the time for guests.
  • (Some of VirtualBox's time synchronization features depend on guest additions.)
  • By default VirtualBox corrects Virtual Machine guests' virtual hardware system clock,
    • when they get powered on,
    • when they resume from suspension and
    • when their clock is more than X minutes off.

KVM's Time Synchronization Features[edit]

TODO: document

Qubes Time Synchronization Features[edit]

TODO: document

sdwdate Time Sources Criteria[edit]

See sdwdate Time Sources Criteria.

Facts[edit]

People have been using:

  • Tor Browser and Mozilla Firefox in parallel
  • Tails inside VMs and Firefox on the host
  • Tor Browser inside Whonix-Workstation ™ and Mozilla Firefox on the host

Other Facts[edit]

  • Almost no one and no operating system is using Secure Network Time Synchronization or External Clocks by default. Most systems synchronize the system clock using unauthenticated NTP. An adversary tampering with NTP replies or malicious NTP server makes things even worse. Even if there was authenticated NTP, there is a requirement for a distributed trust model.
  • A system not using NTP or using authenticated NTP stands out from most other users.
  • clock jumps are bad: wired: The Inside Story of the Extra Second That Crashed the Web [archive]

Definitions[edit]

  • Time Sanity Check in context of Whonix: Is an init.d script, which checks if the system clock is between build timestamp and expiration date (17 MAY 2033 10:00:00).

Attacks[edit]

A correct system clock is crucial for many reasons (see footnotes for more):

  • Attack 1: Replay attacks [1]
  • Attack 2: Feeding old/outdated/known vulnerable updates and (https) certificates [2]
  • Attack 3: Deanonymizing [3]
  • Attack 4: Linking all sessions to the same pseudonym [4]
  • Attack 5: Locating onion services. [5]

Goals[edit]

Completely Isolated Virtual Time[edit]

Quote https://www.kernel.org/doc/Documentation/virtual/kvm/timekeeping.txt [archive]

4.8) Covert channels and leaks

In addition to the above problems, time information will inevitably leak to the guest about the host in anything but a perfect implementation of virtualized time. This may allow the guest to infer the presence of a hypervisor (as in a red-pill type detection), and it may allow information to leak between guest by using CPU utilization itself as a signalling channel. Preventing such problems would require completely isolated virtual time which may not track real time any longer. This may be useful in certain security or QA contexts, but in general is not recommended for real-world deployment scenarios.

Therefore we want a completely isolated virtual time.

Whonix ™ Time Synchronization Mechanism[edit]

Overview[edit]

  • Whonix ™ leaves the host's system clock or time synchronization mechanism untouched.
  • Whonix-Gateway ™ and Whonix-Workstation ™ are commonly used inside virtualizers and therefore have their own virtual hardware system clocks.
  • Virtualizers time synchronization get disabled by Whonix ™.
  • VM Settings, Hardware Clock: set to UTC.
  • When get powered on, they still get their time from the host. The user is advised to modify the biossystemtimeoffset in Advanced Security Guide, chapter Network Time Synchronization. [6]
  • Time Sanity Check before sdwdate will be executed, this ensures, that the host clock is sane and not slow in 1980. User gets advised to fix its host clock in such cases.
  • After they are connected to the Tor network, they use sdwdate (inspired by tails_htp [archive]) to set the system clock. [7]
  • Time Sanity Check after sdwdate was executed. This should catch eventual bigger bugs and attacks. User gets informed if it fails.
  • Using Boot Clock Randomization [archive], i.e. after boot, the clock is set randomly between 0 and 180 seconds into the past or future. This is useful to enforce the design goal, that the host clock and Whonix-Workstation ™ clock should always slightly differ. It is also useful to obfuscate the clock when sdwdate itself is running, because naturally at this time, sdwdate hasn't finished.
  • sdwdate runs after booting.
  • Whonix-Gateway ™: Using sdwdate is better against Attack (1) when using a bridge.
  • Every hour, at a random time, sdwdate will set the clock again. This is useful for machines running for long time periods without reboot.
  • sdwdate runs at non-predictable times to prevent the ISP or Tor guard/bridge node to guess, that the user is running Whonix ™.
  • sdwdate adds or subtracts a random amount of seconds in range of 0.000000001 and 0.999999999. [8] This is supposed to prevent time servers tracking individual users.
  • That will reach the design goal, that all clocks, the host's, Whonix-Gateway ™ and Whonix-Workstation ™ slightly differ.

Block Networking until sdwdate Finishes[edit]

TODO: expand

This is not yet enabled by default.

Network access will be limited to Tor and sdwdate until network time synchronization is done to prevent accidental traffic before that is done.

Whonix ™ firewall runs in two different modes. After boot it runs in timesync-fail-closed mode.

OK: First run during current boot, therefore running in timesync-fail-closed mode.
OK: (Only local Tor control port connections and torified sdwdate allowed.)

Otherwise after sdwdate succeeded or after manually reloading Whonix ™ firewall it runs in full mode.

OK: Consecutive run during current boot, therefore running in full mode.
OK: (Full torified network access allowed.)

Users are encouraged to test so we can enable it by default in the future.

https://forums.whonix.org/t/testers-wanted-blocking-networking-until-sdwdate-finished-status-of-sdwdate-gui/5372/6 [archive]

Instructions:

Network_Time_Synchronization#Block_Networking_until_sdwdate_Finishes

boot clock randomization[edit]

Introduction[edit]

The TimeSync page notes:

Using Boot Clock Randomization, i.e. after boot, the clock is set randomly between 0 and 180 seconds into the past or future. This is useful to enforce the design goal, that the host clock and Whonix-Workstation ™ clock should always slightly differ. It is also useful to obfuscate the clock when sdwdate itself is running, because naturally at this time, sdwdate hasn't finished. sdwdate runs after booting.

By randomly moving the system clock a few seconds (and nanseconds) in the past or future during boot, this enforces the design goal of a slightly different host clock and Gateway/Workstation clock, even before secure timesync has succeeded. This prevents time-based fingerprinting and linkability issues, thereby improving anonymity and privacy. [9]

For technical discussion on the Boot Clock Randomization design, see here [archive]. [10]

Log Inspection[edit]

sudo journalctl -b --no-pager -u bootclockrandomization

Conclusions[edit]

When the user powers on Whonix-Gateway ™ and the host time is too much off, it will not be able to connect to the Tor network. It is advised, when powering on Whonix-Gateway ™, to check that the host time is no more than 1 hour in past or more than 3 hour in future, otherwise Tor will be unable to establish circuits.[11]

An adversary tampering with the user's clock, while the user doesn't recognize that, can't do any more damage to Whonix ™ than he could do to Tor Browser. Worst case is a denial of service for Tor. On the other hand, an adversary capable of actively tampering with the traffic between the user and its entry guard or bridge poses much bigger risks to Tor in general. [12]

The reason for running TimeSync on Whonix-Gateway ™, is that onion services can only be accessed if the clock is no more than 30 minutes slow or fast.[13] Running TimeSync ensures, that Whonix-Gateway ™ clock is reasonably accurate.

Adjusting time slowly using adjtimex/ntp_adjtime[edit]

Under consideration [archive] is changing the time with sclockadj2. The initial drive for this was that calling clock_settime() in the original sclockadj can result in several thousand entries in systemd's journal per invocation (can be seen with journalctrl -f) on Debian.

sclockadj2 uses adjtimex call in libc (als called ntp_adjtime) which translates to Linux' kernel system call 124. This is a modal interface that is used by `ntpd` to change the system clock. adjtimex supports a mode with "hard" changes to the time, but those generate entries in systemd journal, just like with clock_settime.

The offset mode for adjtimex allows a change of 0.5 seconds per call (used to be ~130 milisec until the 2.6 kernel). The documentation of this call is incomplete, partly resulting from the limited number of clients (ntpd, chronyd) using this interface, but by tracing the kernel internals (linux/kernel/time/ntp.c and /linux/kernel/time/timekeeping.c) one can get a more complete picture, including that modern kernels support a NANO mode easier implementation of smaller adjustments than the older μsecond based interface, without the need to do clock tick adjustment calculations.

Based on this interface and mode bit definitions taken from /usr/include/linux/timex.h (more complete than the counterparts you typically find online) to form a Python based interface via ctypes. Primarily first setting the kernel internals to handle nanoseconds specifications and run in PLL mode. Then using OFFSET to adjust the time. With this call the kernel is instructed to change the time gradually. You can observe this change by making further calls to adjtimex, this time without setting any values (specified by 0 in the modes bitfield of the structure handed to adjtimex). To handle changes of more than the maximum allowed (±0.5 seconds), you need to invoke a 0.5 second change and observe if the offset has been reduced to 0, then invoke again. Writing a new offset using adjtimex will overwrite any running adjustment process, therefore you have to wait.

By default the kernel uses a decreasing stepsize as the (remaining) offset to handle approaches 0. This can be influenced by the TIMECONST to start with bigger steps, or even reset the stepsize on a regular basis while the kernel is changing the clock according to the remaining offset.

The ntpd can use this offset changing possibility as is but also has a more sophisticated approach, by instructing the kernel about the drift compared to the internal clock.

The sclockadj2 directly uses a nanosecond offset (positive or negative) that instructs the kernel to adjust (looping multiple invocations if the absolute value of the offset > 0.5 seconds. The program has to be run as root in order to tell the kernel to make these changes (querying the status doesn't require this). At the start of this process a PID file is written, which is checked during loops (if running longer than 0.5 s) and will kill any previous invocation of the program. The syntax for the offset invocation is:

     sclockadj2 offset [-h] [--constant CONSTANT] [--verbose] [--quiet][--wait]  nanoseconds

for changes > 0.5s --wait has to be specified. Increased verbosity can be used to watch the progress of what the kernel is doing with the offset.

This progress can also be seen by invoking the program with the status option. To do so has some instructional value for observing normal `ntpd` behaviour as well. The full options for status:

   usage: sclockadj2 status [-h] [--follow] [--set] [--verbose] [--quiet]
                            [--debug] [--wait]
   adjtimex status (--quiet → only offset, --verbose → detail)
   optional arguments:
     -h, --help     show this help message and exit
     --follow, -f   follow status indefinitely
     --set          set status explicitly to PLL and NANO
     --verbose, -v  increase verbosity level
     --quiet, -q    decrease verbosity level
     --debug, -D    Debug messages. Don't change date
     --wait         wait for offset to return to 0

Stopping a previous invocation of sclockadj2 (which might be looping on values > 0.5s), including stopping the internal offset can easily be achieved by calling sclockadj2 offset 0

External Clock[edit]

This topic is still under research. Help is welcome.

It might make sense to add an external clock, such as a GPS, or even better an atomic clock. (Can we get an atomic USB clock?) This clock should be added to the host and/or Whonix-Gateway ™ and/or Whonix-Workstation ™?

Open question: would the GPS/atomic clock be too accurate and would that make Whonix ™ more fingerprintable?

Discarded Options[edit]

NTP[edit]

tlsdate[edit]

https://github.com/ioerror/tlsdate [archive]

Pros:

  • uses seccomp
  • written by Jacob Appelbaum (security researcher; The Tor Project staff member) Due to the recent news now probably abandoned.

Cons:

  • Only native SSL CA pinning support. No direct SSL certificate pinning support.
  • Does not distribute trust. [20] [21] [22] The single time source can send by error or by malicious intent send wrong time replies.
  • Does not support hooks for user notifications about state of network time synchronization. → Users shouldn't use the internet in Whonix-Workstation ™ before network time synchronization finished, and timesync is informing users about this. → Implementing notifications would be difficult or require patching tlsdate.
  • Produces clock jumps, which confuses various applications. Does not gradually adjust as sdwdate does with Slow Clock Adjuster [archive]. [23]
  • Cannot connect to (most) Tor onion services, because most of those do not support SSL. [24] [25]
  • Minor: command line parser doesn't fail closed on extraneous / unknown command line parameters [26] - not that important in the absence of bugs, butsafer behavior for tlsdate would be to fail closed on on extraneous / unknown command line parameters.
  • Likely denial of service issue: https://github.com/ioerror/tlsdate/issues/149 [archive]

htpdate[edit]

Original.

Tails htpdate fork

Manual Time Setting[edit]

Prompt are very difficult.

  • GUI users:
    • Whonix users: Most laymen don't know what UTC is. Timezone/location should not be asked for privacy reasons too. Users would have to set the time in UTC. At probably a popup would say "use the clock widget and set clock in UTC" which is bad usability.
    • Kicksecure users: Prompt could be in the timezone as defined by user during installer. Slightly less worse.
  • CLI users:
    • Servers: no prompt possible for a server that reboots (such as after forced server restart).

TODO[edit]

Consideration no TimeSync on Host[edit]

Would it be advisable to run no network time synching daemon on the host at all? There are open questions. See:
https://forums.whonix.org/t/ntp-possible-skew-per-day-month-year/487/5 [archive]

Time Source of Time Servers[edit]

Even if we could very securely obtain the time from a server with distributed trust and everything, the question is, how do these servers themselves set their own clock? If they just use unauthenticated NTP themselves, they might not be a big help.

TODO: invent sdwdate-server

Local Clock Leaks[edit]

  • TCP Sequence Numbers → tirdad [archive] [28]
  • ICMP timestamps → blocked by Whonix ™ firewall for Whonix ™ VMs. Host: Recommendation to disable on the host.
  • TCP timestamps → blocked in Whonix ™ VMs by tcp-timestamps-disable [archive].; Recommendation to disable on the host.
  • NTP [16] [17] → Not installed by default in Whonix ™. Host: TODO
  • Automatic updaters and other network using cron jobs that run at non-random, canned [29] times.
  • Javascript. [30] [31]
  • E-mail clients such as Mozilla Thunderbird and others.[32] [33] [34] [35]
  • https / ssl, older [36] versions of openssl, TLS HELLO gmt_unix_time [37] What about other implementations of SSL / TLS, other than openssl?
  • older [36] versions of Tor (NETINFO) [38]
  • web servers (time stamps from http headers (RFC 2616)) [39]

Tor Consensus Method[edit]

Introduction[edit]

Just an idea. Not implemented.

Tails' tordate [archive] (Guessing time based on Tor consensus [archive]), renamed to anondate for trademark reasons and refactored to work outside of Tails provides useful bash functions to check system clock using Tor's consensus file and Tor's log.

https://github.com/Whonix/helper-scripts/blob/master/usr/sbin/anondate [archive]

Tor connects to the network. The Tor consensus file contains rough time information. Since when and until when it is valid.

tordate (now anondate) can provide us with a few machine readable infos we can then use for whatever we may need them.

This is magic.

valid-after=2014-07-31 21:00:00
valid-until=2014-08-01 00:00:00

This is simply /bin/date.

Current time is 2014-07-31 22:44:02

Less magic.

Current time is in valid Tor range

Less magic, but maybe useful.

Current time is not in valid Tor range, setting to middle of this range: [2014-07-31 22:30:00]

anondate can do this by parsing Tor's verified consensus file /var/lib/cached-microdesc-consensus or by parsing /var/lib/tor/unverified-microdesc-consensus.

Tor Consensus Download and Verification Conditions[edit]

Under which conditions Tor is not able to verify the Tor consensus file?

1) If it has been tampered with by a man-in-the-middle.

2) For clocks that are more than 30 days in the past or 2 days in the future, Tor will not even be able to download a consensus. In this case anondate can parse Tor's log and report the authority's cert's valid-after date. [40]

anondate --tor-cert-valid-after
Jun 16 00:00:00 2014 GMT
Open Questions[edit]
  • Is the authority's cert's valid-after date signed/verified/built-into-Tor or can it be tampered with by a man-in-the-middle attack?
  • When clock is more than 1 hour in past or more than 3 hour in future, Tor will be unable to establish circuits? [41]
Required Clock Accuracy for Onion Services Accessibility[edit]

live consensus definition, quote Tor Tor directory protocol [archive]:

A network-status document is "live" if the time in its valid-after field has passed, and the time in its valid-until field has not passed.

reasonably live consensus definition, quote Tor Tor directory protocol:

A reasonably live consensus is one that expired less than 24 hours ago.

How accurate has the clock to be so onion services can be accessed? [42]

Due to issue Most Onions Down due to a Denial of Service Attack on the Tor Network [archive] this question received attention.

Previously a live consensus was required. From Tor 0.4.5.3 and above only a reasonably live consensus will be required.

Reasons for relying solely on anondate for time setting[edit]
anondate issues[edit]

Originally posted in sdwdate Tor Consensus Time Sanity Check [archive]:

  • As per chat log with Roger [archive] directory authorities can lie about time - so we need to use this with care.
  • Tor consensus isn't always downloaded from directly from directory authorities, sometimes Tor downloads the Tor consensus from directory mirrors. And the latter aren't trusted as much as directory authorities. Those are just like normal relays.
  • We should have the courtesy to not explicitly download from directory authorities, because...

    armadev: oh. i think that would be horrible. hundreds of thousands of users doing that could overwhelm the directory authorities.

Reasons against relying solely on anondate for time setting[edit]
  • Provides only rough time.
    • web fingerprint would differ from most other Tor users.
    • Would cause lots of support requests complaining about skewed clocks.
    • Might trouble onion services (such as hidden web servers) that need to show time to clients?
    • Might trouble people attempting to tunnel I2P through Tor?
    • Might cause other (gpg) verification issues?
      • Debian updater APT refuses to use sources which are not yet valid. I.e. source with a signed valid-until field later than the local system clock.
  • Fingerprinting issues at ISP level:
  • Hidden services can only be accessed if the clock is no more than 30 minutes slow or fast. [43]
  • Tails ticket: Robust time syncing [archive] Quote:

    Currently we use tordate to set the initial clock. It is very messy and error prone, so we desperately need a robust replacement.

  • Vulnerable to ISP level man-in-the-middle attacks:
    • Tails Design: Time Syncing [archive] Quote:

      First, replaying a consensus older than one week or so results in preventing access to the Tor network, and that's all, because onion keys will be wrong.

      • In a situation where an adversary is replaying a more than ~7 days old consensus:
        • anondate could report a clock that is more than ~7 days slow. With a system clock that is that slow, Tor would no longer be able to establish circuits. But there are multiple reasons why Tor may not be able to establish circuits. So anondate could only guess, that the clock reported in Tor consensus is more than ~7 days slow, but not know with certainty.
      • In a situation where an adversary is replaying an up to ~7 days old consensus:
        • anondate could report a clock that is up to ~7 days slow and Tor would still be able to create circuits.
        • With Tor as is at the moment, anondate cannot even in principle provide a more accurate time guess than a clock that is up to ~7 days slow.
        • Using an up to ~7 days old consensus, is most likely something we really should avoid?
    • Therefore vulnerable to Attack 3 as per #Attacks.
Conclusions[edit]
  • Relying solely on anondate for time setting is probably a bad idea.
  • Tor consensus time is used as a sdwdate Tor Consensus Time Sanity Check.
  • Rough time fix.
    • If clock is too much off so sdwdate cannot fix it, use anondate to get a rough time fix, then let sdwdate do the rest.
Why not use tordate by Tails instead of reinventing the wheel with anondate?[edit]
  • Because Tails code is highly Tails specific.
    • Depending on non-persistent Tor data dir.
    • Entangled with Tails specific gui notifications.
    • Entangled into the Tails specific boot process with other scripts.
    • Not a clean abstraction of "tell me what Tor's log / Tor's consensus thinks about date/time".
    • Quote: "Currently we use tordate to set the initial clock. It is very messy and error prone, so we desperately need a robust replacement." [44]
Random Stuff[edit]

Tor Certificate Lifetime[edit]

certificate lifetime

Certificate not yet valid. Either their clock is set wrong, or your clock is wrong.
(certificate lifetime runs from Aug 27 00:00:00 2020 GMT through Aug 27 00:00:00 2021 GMT. Your time is Jan 09 07:33:33 2000 UTC.)

sudo anondate --tor-cert-valid-after

Aug 27 00:00:00 2020 GMT

Might be related to the following. Quote Tor Tor directory protocol [archive]:

Every authority has a very-secret, long-term "Authority Identity Key". This is stored encrypted and/or offline, and is used to sign "key certificate" documents. Every key certificate contains a medium-term (3-12 months) "authority signing key", that is used by the authority to sign other directory information. (Note that the authority identity key is distinct from the router identity key that the authority uses in its role as an ordinary router.)

While Authority Identity Key might be hardcoded in Tor, the certificate lifetime is likely not. Otherwise Debian (old)stable would have to ship yearly upgrades to upgrade the "Tor directory authority certificate start date" which never happens. Therefore certificate lifetime should not be trusted since it could be stale.

Tor Certificate Lifetime likely has a digital software signature which gets verified by Tor. It's however not a trustworthy source of time. Vulnerable to replay attacks. Could be one year or older. That's because to verify its freshness, Tor requires a correct clock. For time synchronization purposes however the clock is assumed to be incorrect. What however could be trusted that at least that time has already come. It's not a far future date because then Tor directory authorities wouldn't have signed a Tor certificate with that lifetime yet.

Related source code: https://src-ref.docs.torproject.org/tor/x509__openssl_8c.html#adcb9e22c87cb9ba135f6edf3e13386b4 [archive]

Related ticket: https://gitlab.torproject.org/legacy/trac/-/issues/4370 [archive]

Tor Consensus Issues[edit]

Quote [archive] Roger Dingledine:

Whether this is a good idea depends on where you got the consensus. If you connect to a Tor directory mirror and it hands you a consensus from last month, and you set your clock based on it, then you've opened yourself up to exactly the attack that Tor is trying to defend against.

Problem is, nowadays Tor in most cases doesn't download from Tor directory authorities anymore. And we ought to not download the Tor consensus exclusively from Tor directory authorities. Source: [45]

<armadev> oh. i think that would be horrible. hundreds of thousands of users doing that could overwhelm the directory authorities.

https://forums.whonix.org/t/tor-dev-mailinglist-proposal/489/print [archive]

Fixing Time based on Tor Consensus[edit]

Future Implementation consideration.

This could be how time syncing is performed when Whonix ™ starts:

Credits: This is a rewrite of Tails Time Syncing Design [archive]

  1. Start Tor. If Tor is already working, skip to the following anondate steps.
  2. Let Tor fetch the Tor consensus.
  3. (anondate related step) If the time is too badly off, the Tor directory authority certificate may not be valid, so we set the system time to the Tor directory authority certificate start date. (sudo anondate --tor-cert-valid-after) For example, see above. Which will guarantee that the Tor directory authority certificate will be valid and the Tor consensus (which includes Tor valid-until date/time) can be downloaded.
  4. (anondate related step) Wait until Tor can tell us the Tor valid-until date/time.
  5. (anondate related step) Set system time to Tor consensus time valid-until - 1:30. (In other words: minus 1 and 30 or minus 90 minutes.) (sudo anondate --show-middle-range) [46]
  6. Wait until the Tor bootstrap process has been completed.
  7. Use sdwdate (which exclusively uses onions as time sources) though Tor to get a more correct system time.

A notification in form of sdwdate-gui shown while the whole process is running.

Non-issues:

  • Use of unverified Tor consensus is not required.
  • The hardware clock is not affected.

Security discussion:

sdwdate's approach essentially removes Tor's time skew check, which is used to prevent replay of consensus data. Let's discuss this class of attacks.

First, replaying a consensus older than four weeks or so results in preventing access to the Tor network, and that's all, because onion keys will be wrong. An attacker who is in a position to replay a consensus to the user could anyway do this, unrelated to time, so the issue at hand boils down to replaying a consensus not older than four weeks or so.

Second, the same type of attacker as above could also try to forge a completely new consensus, which would be unverifiable since the attacker doesn't have access to the authorities' keys. An attacker in that position could do denial-of-service attacks in many other ways, so this doesn't make the situation any worse.

Third, things are different depending on if the user is using a bridge or not.

If not using a bridge, first boot:

  • Tor starts without a cached consensus.
  • The Tor client starts by connecting directly to a fallback directory mirror [archive] to download the Tor consensus.
  • Feeding a stale consensus requires the attacker either to break SSL or to control the fallback directory mirror the user's Tor client connects to.
  • Under these conditions the adversary could feed an up to four weeks stale Tor consensus, which is used until sdwdate has fixed the time.
  • Not good, but probably a compromise we can make.

If using a bridge, first boot:

  • Tor starts without a cached consensus.
  • Tor fetches Tor consensus from the bridge.
  • Feeding a stale consensus requires the attacker either to break SSL or to control the user's bridge.
  • Under these conditions the adversary could feed an up to four weeks stale Tor consensus, which is used until sdwdate has fixed the time.
  • Not good, but probably a compromise we can make.

If your ISP, Tor entry guard or Tor bridge, can also:

  • A) set up an onion MitM attack against the sdwdate onion connections, and/or
  • B) controls onions used by sdwdate as time sources,

it can trick you into keep using this old consensus for max. four weeks, which is much worse.

A) should be extremely unlikely. A successful MitM against a Tor onion connection have never been reported. While Tor onions servers might be vulnerable to various de-anonymization attacks, this is a different topic, this affects only the anonymity of the onion server. The client, visitor (here user's machine using sdwdate) does not have to worry about this. Also does not affect the encryption/authentication of the connection. No reports of breaking onion encryption/authentication where known at time of writing. If this was possible, this would be catastrophic anyhow. This wouldn't make the situation any worse.

B) should also be very unlikely. Onion servers targeting specific users seems very unlikely since users connect anonymously using Tor to an onion server. An attack against all users is also very unlikely since sdwdate is distributed (uses median of 3 onion time sources), randomly chosen from sdwdate time sources list and such an attack would be easy to notice, probably reported by users and in response developers would remove these sdwdate time sources.

In any case it should be better than using unauthenticated NTP.

Tor Consensus Time Setting Method Security Considerations[edit]

User local system clock being much skewed is a big issue because:

  • a) Stands out in javascript snooping scripts (Even if Tor Browser fixed that, other applications could leak it.)
  • b) Prevents Tor consensus from being downloaded leading to broken Tor connectivity.
  • c) Other issues discussed on top of this page, Time Attacks.

It depends on the start conditions. Seems really complex. The user's clock is either:

  • [C]: correct
  • [D]: incorrect

The Tor directory mirror (just normal relays) is either sending the user a Tor consensus that is:

  • [E]: fresh
  • [D]: legitimate (bug) stale
  • [F]: malicious (targeted attack) stale
  • [G]: invalid

Now these are quite a few cases to combine and consider. [G] we can ignore. [D] and [F] can be regarded as approximately the same issue.

user clock slow [D] + stale Tor consensus [F]: user would remain on fake Tor network

user clock correct [C] + stale Tor consensus [F]: anondate would introduce a time skew. Not fix one. The user's system clock would be set to the past because the stale Tor consensus told anondate so. The worst could be prevented with a hardcoded minimum date as a safeguard but it's still a security compromise to make.

user clock slow [D] + fresh Tor consensus [E]: In this case anondate would fix the connectivity/usability issue, fix a) and b).

Then it also depends on how slow the user's clock is.

  • [H] Less than 24 hours slow clock or
  • [I] More than 24 hours slow clock.

Therefore:

  • [H] + a): issue
  • [I] + a): no issue since no connection

Blockchain Time[edit]

NTS - Network Time Security - Secure NTP[edit]

roughtime[edit]

roughtime information[edit]

roughtime client list[edit]

Debugging[edit]

Useful to run in Qubes dom0.

qvm-run --pass-io sys-whonix "date -u" ; date -u

See Also[edit]

Other[edit]

Previous Discussion[edit]

Other Projects[edit]

Comparison with Others[edit]

Network Time related

Tickets[edit]

Qubes[edit]

high priority[edit]

normal priority[edit]

others[edit]

Clock Correlation Attack[edit]

Attack[edit]

prerequisite knowledge:

  • Whonix-Gateway ™ [Proxy]VMs and Whonix-Workstation ™ [App]VM's system time cannot not be obtained by watching traffic at ISP level.
  • This chapter is not about tracking a single VM across its different Tor exit relays.
  • The context is anonymity. The significance is deanonymization.
  • In anonymity we don't just care about about correlations. Also about estimations. Anonymity set reduction. Partitioning users is already a success. Because it may be combined with other guesses. No direct proof is required. From some countries, there are just a few 100 users or less. If there is already a lead by country, then combined with these time related issues, things begin to really matter.
  • clocksource 'xen' / 'kvmclock' doesn't prevent Whonix ™ from using sdwdate.
  • clocksource 'xen' / 'kvmclock' doesn't prevent each VM having slightly different system time (used by all the applications), so no direct leaks here.
  • [host | dom0] host time and VM times a very, very similar. At most one second difference. Or less. In [host | dom0], see:
date ; qvm-run --pass-io sys-net date

Attack:

  • 1) requires a) compromise a Whonix-Workstation ™ VM and b) observing the ISP network the user is using
  • 2) read [host | dom0] time using clocksource 'xen' / 'kvmclock' or possibly the wall clock interface
  • 3) [host | dom0] time will be very similar to NetVM's time (the system where external network connections are made)
  • 4) correlate Whonix-Workstation ™ VM with NetVM's time
  • 5) anonymity set reduction done

Notes:

No need to compromise multiple VMs. Only one VM, a Whonix-Workstation ™ VM needs to be compromised. NetVM does not have to be compromised, it leaks in most cases - hard to avoid all cases - any passive ISP level adversary watching traffic can read the clients local clock. It is leaked on many levels, see #Local Clock Leaks.

Threat Model:

  • Whonix-Workstation ™ AppVM gets compromised up to local root code execution. Then the attacker uses the local exploit, reads clocksource 'xen' / 'kvmclock'.

Defense[edit]

We need to make sure that all of Whonix-Gateway ™, Whonix-Workstation ™, and NetVM uses slightly different time. Even if Whonix-Workstation ™ would be compromised, and the attacker gets knowledge of the time of [host | dom0] and sniffs NetVM's time, it would hinder correlation.

[host | dom0] and non-anonymous VM's clocks should be as synced, correct and secure as those can be.

But those should differ from the clocks within Whonix ™ VMs.

We need completely isolated virtual time within Whonix ™ VMs. [47] [48]

wallclock[edit]

> The other interface ("wallclock interface") would provide such time, though. And it is not configurable. But not sure if it is used anywhere in Linux by default (probably besides initial system time set).

Yes. Must be so. Otherwise with "ticks" alone the VM had no chance to figure out the current time. And this is a roblem, because we don't want the VM to know [host | dom0]'s time.

We might be able to solve the wallclock [not pvclock] issue by Spoofing the Initial Virtual Hardware Clock Offset.

Development[edit]

Rather than modifying [host | dom0]'s clock, we could perhaps spoof the initial virtual hardware clock offset. It is possible for KVM, as per: https://libvirt.org/formatdomain.html#elementsTime [archive]

Something like this:

<clock offset='variable' adjustment='123456' basis='utc'>

Reading clocksource xen as a [root] user is not easily possible. source: http://lists.xen.org/archives/html/xen-users/2015-08/msg00020.html [archive]

Would probably require writing a kernel module.

Sources[edit]

TSC[edit]

Needs more research.

Why we should avoid leaking TSC from the host go the VM.

Leaking anything related to time from the host into the VM [or from VM to VM] risks cryptographic side channel attacks and should therefore be avoided.

Search term:
time stamp counter tsc side channel

Leads to:
http://blog.cr0.org/2009/05/time-stamp-counter-disabling-oddities.html [archive]

TSC leaks may be similar to TCP sequence numbers. [49]

clocksource xen[edit]

https://github.com/QubesOS/qubes-issues/issues/1764#issuecomment-195619793 [archive]

Resources[edit]

Footnotes[edit]

  1. Replay old Tor consensus, see Tails: Time syncing [archive] for detailed explanation.
  2. Cryptographic verification depends on system clock, i.e. a clock two years in past will accept certificates/updates, which have been expired/revoked for two years.
  3. #Local Clock Leaks are an issue. Imagine the user connects to an adversary controlled web-server with Mozilla Firefox and connects to another web-server controlled by the same adversary with Thunderbird. The adversary can link the anonymous and non-anonymous session, thus deanonymizing.
  4. If the clock is too much off, it is also easy for an adversary's web-server to detect "Oh, that's the Tor Browser user who's clock is X in past/future.", thus allowing the adversary to link all sessions to the same pseudonym. See Tor Browser upstream bug #3059: Find some way to deal with time-based fingerprints [archive].
  5. For onion services a correct clock is crucial, see:
  6. Developer information: If we needed or wanted to render the hardware clock unusable, we could set VirtualBox --biossystemtimeoffset several decades in past or future.
  7. Stream isolation has been added, for Whonix ™ sdwdate implementation i.e. people using Tor Browser prevent notifying their exit relay, that they are sdwdate or Whonix ™ users.
  8. Check.
    grep -i "Made up" /var/log/sdwdate.log
    
  9. https://github.com/Whonix/bootclockrandomization [archive]
  10. Notably, one recent change is the 0-5 second time window is no longer excluded in the process, as it was found to aid fingerprinting.
  11. https://lists.torproject.org/pipermail/tor-talk/2012-February/023264.html [archive]
  12. General Tor problems, Tor is known to be broken against many active attacks. This can not be solved by Whonix ™. When an adversary is capable of running active attacks, tampering with the time leading into a denial of service is the least of the worries. The adversary could also disrupt the service easier. And as for active attacking in general, there are other attacks which are easier to deploy and which pose a greater danger. Not a Whonix ™ specific problem.
  13. https://trac.torproject.org/projects/tor/ticket/3582#comment:3 [archive]
  14. http://lists.ntp.org/pipermail/questions/2010-November/028033.html [archive]
  15. https://labs.riseup.net/code/issues/6113 [archive]
  16. 16.0 16.1 Source: RFC5905 [archive]

    Origin Timestamp (org): Time at the client when the request departed for the server, in NTP timestamp format.

  17. 17.0 17.1 Credits: Thanks to dfc [archive] for the answer on security.se [archive].
  18. http://www.webcitation.org/6ST27IXN6 [archive]
  19. 60 s * 60 m * 24 h
  20. As sdwdate does.
  21. https://github.com/ioerror/tlsdate/issues/112 [archive]
  22. https://github.com/ioerror/tlsdate/issues/143#issuecomment-57053323 [archive]
  23. sclockadj [archive]
  24. Because in most cases, there is little need to combine Tor onion services with SSL. connections to Tor onion services are Tor-to-Tor encrypted by default ("not exactly end-to-end").
  25. https://github.com/ioerror/tlsdate/issues/157 [archive]
  26. https://github.com/ioerror/tlsdate/issues/158 [archive]
  27. https://tails.boum.org/contribute/design/Time_syncing/#index4h1 [archive]
  28. By distribution defaults.
  29. Was fixed [archive] in Tor Browser, but remains open for other applications such as browsers like Mozilla Firefox.
  30. See http://ip-check.info [archive] for demonstration.
  31. As of June 2016, Iceweasel has been replaced by Firefox-ESR in Debian, see https://wiki.debian.org/Iceweasel [archive]
  32. prevent leak via Date header field (local timestamp disclosure) [archive]
  33. prevent leak via Message-ID header field (local timestamp disclosure) [archive]
  34. Quote, on October 24th, 2014 sukhbir said [archive]:
    "The timestamp disclosures are via the date and the message-ID headers (relevant tickets: #6314 [archive], #6315 [archive]). We have submitted patches to Mozilla (902573 [archive], 902580 [archive]) that have not yet been merged. The patches probably need more work and we are looking for volunteers to work on them and help us to get them merged. We will be doing a blog post about this soon and put out a call for help."
  35. 36.0 36.1 For example the one shipped by Debian wheezy.
  36. https://trac.torproject.org/projects/tor/ticket/8751 [archive]
  37. See torproject.org #4852: Clients send NETINFO with time [archive]. The ticket says fixed. However, Debian wheezy (which Whonix ™ 10 was based on) was using Tor 0.2.3 [archive] but Nick's patch appeared first in 0.2.4 [archive]. It was solved in Whonix ™ 11, because it was based on Debian jessie, that contained a more recent version of Tor [archive].
  38. For demonstration, you could use.
    curl -silent --head torproject.org | grep -i date:
    
  39. Source, source code comment in tordate: https://git-tails.immerda.ch/tails/plain/config/chroot_local-includes/etc/NetworkManager/dispatcher.d/20-time.sh [archive]
    	# Since Tor 0.2.3.x Tor doesn't download a consensus for
    	# clocks that are more than 30 days in the past or 2 days in
    	# the future.  For such clock skews we set the time to the
    	# authority's cert's valid-after date.
    
  40. https://lists.torproject.org/pipermail/tor-talk/2012-February/023264.html [archive]
  41. https://trac.torproject.org/projects/tor/ticket/3460 [archive]
  42. https://trac.torproject.org/projects/tor/ticket/3582#comment:3 [archive]
  43. https://labs.riseup.net/code/issues/5774 [archive]
  44. https://forums.whonix.org/t/tor-dev-mailinglist-proposal/489/10 [archive]
  45. anondate --show-valid-after

    2021-01-09 13:00:00
    

    sudo anondate --show-valid-until

    2021-01-09 16:00:00
    

    anondate --show-middle-range

    2021-01-09 14:30:00
    
  46. http://security.stackexchange.com/questions/106406/how-to-get-a-completely-isolated-virtual-time-using-xen [archive]
  47. http://lists.xen.org/archives/html/xen-users/2015-11/msg00114.html [archive]
  48. https://trac.torproject.org/projects/tor/ticket/16659#comment:10 [archive]

License[edit]

Whonix ™ Dev/TimeSync wiki page Copyright (C) Amnesia <amnesia at boum dot org>
Whonix ™ Dev/TimeSync wiki page Copyright (C) 2012 - 2021 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>

This program comes with ABSOLUTELY NO WARRANTY; for details see the wiki source code.
This is free software, and you are welcome to redistribute it under certain conditions; see the wiki source code for details.



text=Jobs in USA
Jobs in USA


Search engines: YaCy | Qwant | ecosia | MetaGer | peekier | Whonix ™ Wiki


Follow: 1024px-Telegram 2019 Logo.svg.png Iconfinder Apple Mail 2697658.png Twitter.png Facebook.png Rss.png Reddit.jpg 200px-Mastodon Logotype (Simple).svg.png

Support: 1024px-Telegram 2019 Logo.svg.png Discourse logo.png Matrix logo.svg.png

Donate: Donate Bank Wire Paypal Bitcoin accepted here Monero accepted here Contriute

Whonix donate bitcoin.png Monero donate Whonix.png United Federation of Planets 1000px.png

Twitter-share-button.png Facebook-share-button.png Telegram-share.png Iconfinder Apple Mail 2697658.png Reddit.jpg Hacker.news.jpg 200px-Mastodon Logotype (Simple).svg.png

Have you contributed to Whonix ™? If so, feel free to add your name and highlight what you did on the Whonix ™ authorship page.

https link onion link

This is a wiki. Want to improve this page? Help is welcome and volunteer contributions are happily considered! Read, understand and agree to Conditions for Contributions to Whonix ™, then Edit! Edits are held for moderation. Policy of Whonix Website and Whonix Chat and Policy On Nonfreedom Software applies.

Copyright (C) 2012 - 2021 ENCRYPTED SUPPORT LP. Whonix ™ is a trademark. Whonix ™ is a licensee [archive] of the Open Invention Network [archive]. Unless otherwise noted, the content of this page is copyrighted and licensed under the same Freedom Software license as Whonix ™ itself. (Why?)

The personal opinions of moderators or contributors to the Whonix ™ project do not represent the project as a whole.

Whonix ™ is a derivative of and not affiliated with Debian [archive]. Debian is a registered trademark [archive] owned by Software in the Public Interest, Inc [archive].

Whonix ™ is produced independently from the Tor® [archive] anonymity software and carries no guarantee from The Tor Project [archive] about quality, suitability or anything else.

By using our website, you acknowledge that you have read, understood and agreed to our Privacy Policy, Cookie Policy, Terms of Service, and E-Sign Consent. Whonix ™ is provided by ENCRYPTED SUPPORT LP. See Imprint, Contact.

By using our website, you acknowledge that you have read, understood and agreed to our Privacy Policy, Cookie Policy, Terms of Service, and E-Sign Consent.