Skip to content

update: Replace unmaintained chrono crate (RUSTSEC-2026-0543) #363

Closed

Description

@inureyes

Problem / Background

cargo deny check advisories reports RUSTSEC-2026-0543: chrono is unmaintained, all versions are affected, and no safe upgrade exists (announcement: chronotope/chrono#1768). The advisory recommends jiff or time. There is no known vulnerability, so this is maintenance work. Ignoring the advisory in .cargo/audit.toml (currently ignore = []) is not an acceptable fix.

bssh depends on chrono directly (Cargo.toml:52, chrono = { version = "0.4.45", features = ["serde"] }) and transitively through russh-sftp 3.0.1 (src/utils.rs and src/protocol/file.rs there use DateTime<Utc>). russh-util 0.52.0 also lists chrono, but only for cfg(target_arch = "wasm32"). Removing the direct dependency therefore does NOT remove chrono from Cargo.lock or clear the advisory; that requires an upstream change in russh-sftp, tracked as an optional task below. No upstream russh-sftp issue about chrono exists today.

Current usage (all real call sites)

  • src/server/audit/event.rs:20,35,188: AuditEvent.timestamp: DateTime<Utc>, serde-serialized, set with Utc::now(). Serialized by the file and logstash exporters, and converted to SystemTime in src/server/audit/otel.rs:144 (event.timestamp.into()).
  • src/ui/tui/log_buffer.rs:20,43,53,85: LogEntry.timestamp: DateTime<Local>, rendered as %H:%M:%S in local time.
  • src/utils/output.rs:34: chrono::Local::now().format("%Y%m%d_%H%M%S") for output file names.
  • src/executor/parallel.rs:1772: chrono::Utc::now().format("%Y%m%d_%H%M%S") for output file names (UTC, unlike output.rs; keep each as-is).
  • src/commands/interactive/multiplex.rs:19,265: use chrono; and chrono::Local::now().format("%H:%M:%S") for interactive timestamps.

Other grep hits for "chrono" (e.g. "synchronous" in server/shell.rs, server/mod.rs, ssh/tokio_client/*) are false positives.

Recommended crate: jiff

Recommend jiff (with serde feature). bssh needs local-time formatting in a multi-threaded tokio process, and time's OffsetDateTime::now_local() returns an error on multi-threaded Unix processes unless the unsound opt-out is enabled, so three of the five call sites would break or silently fall back to UTC. jiff reads the system time zone itself (Zoned::now()), supports strftime-style strftime("%H:%M:%S"), serializes jiff::Timestamp as RFC 3339 with Z, and converts to SystemTime. time 0.3 is already in the tree via hickory, which is the main argument for it; the implementer may choose time only if local time works correctly under tokio without unsound flags.

Tasks

  • Replace chrono with the chosen crate in Cargo.toml and all five call sites above; remove use chrono; from multiplex.rs.
  • AuditEvent.timestamp: use jiff::Timestamp (UTC instant), keeping the serialized JSON field a RFC 3339 UTC string with Z suffix; keep the otel SystemTime conversion.
  • LogEntry.timestamp and the multiplex.rs / output.rs timestamps: keep local time; parallel.rs stays UTC.
  • Confirm the crate's MSRV fits rust-version = "1.97" and that static musl release builds and the vendored Launchpad PPA build still work. (MSRV confirmed: jiff 1.0.1 needs 1.85; musl and PPA builds pending CI/release, PR update: replace unmaintained chrono with jiff #364)
  • Optional: file an upstream issue (or PR) on russh-sftp to replace chrono, and link it here.

Acceptance Criteria

  • chrono is no longer a direct dependency of bssh (cargo tree -i chrono -e normal shows only russh-sftp/russh-util as dependents).
  • A test asserts AuditEvent JSON timestamp is RFC 3339 UTC with Z, and that JSON written by the current chrono-based code (e.g. "2026-11-20T01:02:03.123456789Z" and "2026-11-20T01:02:03Z") still deserializes.
  • Output file names keep the %Y%m%d_%H%M%S format and TUI/interactive timestamps keep %H:%M:%S in local time; existing log_buffer.rs tests pass.
  • cargo fmt --check, cargo clippy -- -D warnings, and the test suite pass.
  • The advisory status is reported honestly in the PR: still present via russh-sftp until upstream changes.

Verification

cargo fmt --check
cargo clippy -- -D warnings
cargo test --lib
cargo test --tests -- --skip integration_test
cargo tree -i chrono -e normal
cargo deny check advisories

Activity

  1. added
    status:ready
    priority:low
    type:dependency
    status:in-progress
    status:review
    and removed
    status:ready
    status:in-progress
    on Nov 19, 2026
  2. added
    status:done
    and removed
    status:review
    on Nov 19, 2026
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

    priority:lowstatus:donetype:dependency

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions