Skip to content

Ignore posts with out-of-range timestamps#466

Merged
dahlia merged 1 commit intofedify-dev:mainfrom
dahlia:future-posts
May 5, 2026
Merged

Ignore posts with out-of-range timestamps#466
dahlia merged 1 commit intofedify-dev:mainfrom
dahlia:future-posts

Conversation

@dahlia
Copy link
Copy Markdown
Member

@dahlia dahlia commented May 5, 2026

#67 reports two bugs caused by fediverse posts with forged timestamps.

Hollo accepted remote posts whose published value was far in the future and sorted them to the top of the federated timeline. UUIDv7 encodes the timestamp in the high bits, and timeline queries order by ID, so a post dated 2038 sorts ahead of posts created today. A remote actor that can deliver a valid ActivityPub object could keep content above newer posts for years.

Hollo also crashed on posts dated before the Unix epoch. Those posts passed a negative millisecond value to uuidv7(), which throws on negative input.

In src/federation/post.ts, persistPost() now validates published and updated after the existing-local-post checks and before any remote network requests. Posts more than 12 hours in the future are dropped before fetches or inserts. Pre-epoch posts are still accepted; the uuidv7() call clamps the timestamp to zero.

onPostUpdated() in src/federation/inbox.ts now checks persistPost()'s return value. Without that, a rejected Update activity could still dispatch quoted_update notifications against the stale pre-update row.

src/federation/post.test.ts covers rejection at 13 hours, acceptance at 11 hours, updated timestamps in the future, and pre-epoch dates no longer crashing uuidv7().

Closes #67.

Incoming ActivityPub posts whose published or updated timestamp is more
than 12 hours in the future are now silently rejected before any remote
dereferencing takes place.  This prevents timeline manipulation via
forged future timestamps.

Posts with a published date before the Unix epoch (e.g. 1963) no longer
crash the server: the UUIDv7 generator was receiving a negative
millisecond value, causing an exception.  The timestamp is now clamped
to zero (Unix epoch) when generating the row ID.

Also fixed onPostUpdated() in the federation inbox: it previously
ignored the return value of persistPost(), so a rejected Update activity
could still dispatch quoted_update notifications for the stale pre-update
row.

Fixes fedify-dev#67

Assisted-by: Claude Code:claude-sonnet-4-6
Assisted-by: Codex:gpt-5.5
@dahlia dahlia added this to the Hollo 0.9 milestone May 5, 2026
@dahlia dahlia self-assigned this May 5, 2026
@dahlia dahlia added the bug Something isn't working label May 5, 2026
@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented May 5, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dahlia dahlia merged commit 74c7047 into fedify-dev:main May 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore posts created or updated in a weird time period

1 participant