Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): reject malformed timestamp #12554

Merged
merged 1 commit into from
Dec 3, 2023
Merged

fix(backend): reject malformed timestamp #12554

merged 1 commit into from
Dec 3, 2023

Conversation

acid-chicken
Copy link
Member

What

リモートの Activity のタイムスタンプによってタイムスタンプ部がクランプされる ID が生成されるとき、その Activity を拒否する

Why

Fix #12401

Additional info (optional)

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@acid-chicken acid-chicken added 🐛Bug Unexpected behavior packages/backend Server side specific issue/PR 🌌Federation The Federation/ActivityPub feature labels Dec 3, 2023
Copy link

codecov bot commented Dec 3, 2023

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (e17d741) 78.79% compared to head (fefce39) 78.76%.

Files Patch % Lines
packages/backend/src/core/IdService.ts 44.44% 10 Missing ⚠️
...ges/backend/src/core/activitypub/ApInboxService.ts 0.00% 7 Missing ⚠️
...ckend/src/core/activitypub/models/ApNoteService.ts 50.00% 2 Missing ⚠️
packages/backend/src/misc/id/aid.ts 50.00% 2 Missing ⚠️
packages/backend/src/misc/id/aidx.ts 50.00% 2 Missing ⚠️
packages/backend/src/misc/id/meid.ts 50.00% 2 Missing ⚠️
packages/backend/src/misc/id/meidg.ts 50.00% 2 Missing ⚠️
packages/backend/src/misc/id/object-id.ts 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12554      +/-   ##
===========================================
- Coverage    78.79%   78.76%   -0.04%     
===========================================
  Files          954      953       -1     
  Lines       103756   103735      -21     
  Branches      8346     8348       +2     
===========================================
- Hits         81756    81707      -49     
- Misses       22000    22028      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Dec 3, 2023

このPRによるapi.jsonの差分

差分はこちら

Get diff files from Workflow Page

@@ -306,9 +306,15 @@ export class ApInboxService {
this.logger.info(`Creating the (Re)Note: ${uri}`);

const activityAudience = await this.apAudienceService.parseAudience(actor, activity.to, activity.cc);
const createdAt = activity.published ? new Date(activity.published) : null;

if (createdAt && createdAt < this.idService.parse(renote.id).date) {
Copy link
Member

Choose a reason for hiding this comment

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

この判定は無いとどんな問題がある?

Copy link
Member Author

Choose a reason for hiding this comment

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

Renote の Note ID が同様の問題を発生させる可能性がある
そもそも Renote が参照先の Note より先に発行されるはずはないため、そういう条件で判定している

Copy link
Member Author

Choose a reason for hiding this comment

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

まぁリモートのサーバーの時計がぶっ壊れてたらここに到達する可能性は否めないが、それは NTP 設定してくれ〜すぎるので

@syuilo syuilo merged commit af15f8d into develop Dec 3, 2023
19 checks passed
@syuilo syuilo deleted the patch-12401 branch December 3, 2023 05:38
@syuilo
Copy link
Member

syuilo commented Dec 3, 2023

🙏🏻

camilla-ett pushed a commit to kaseiski/misskey that referenced this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛Bug Unexpected behavior 🌌Federation The Federation/ActivityPub feature packages/backend Server side specific issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aid/aidx 使用時は 2000-01-01T00:00:00Z 以前のリモート Activity 処理を拒否する
2 participants