summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura Hausmann <laura@hausmann.dev>2024-10-24 05:11:16 +0200
committerJulia Johannesen <julia@insertdomain.name>2024-11-20 19:17:24 -0500
commitb74e2e91674ee56ef0b835daa31f5a72d02ab37d (patch)
treed5de1b87934d7160348211ee764b398d49a4f578
parentfix: primitive 15: improper same-origin validation for note uri and url (diff)
downloadsharkey-b74e2e91674ee56ef0b835daa31f5a72d02ab37d.tar.gz
sharkey-b74e2e91674ee56ef0b835daa31f5a72d02ab37d.tar.bz2
sharkey-b74e2e91674ee56ef0b835daa31f5a72d02ab37d.zip
fix: primitive 16: improper same-origin validation for user uri and url
-rw-r--r--packages/backend/src/core/activitypub/models/ApPersonService.ts28
1 files changed, 24 insertions, 4 deletions
diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts
index 8ddd646f05..7a3bd57d43 100644
--- a/packages/backend/src/core/activitypub/models/ApPersonService.ts
+++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts
@@ -337,8 +337,18 @@ export class ApPersonService implements OnModuleInit {
const url = getOneApHrefNullable(person.url);
- if (url && !checkHttps(url)) {
- throw new Error('unexpected schema of person url: ' + url);
+ if (person.id == null) {
+ throw new Error('Refusing to create person without id');
+ }
+
+ if (url != null) {
+ if (!checkHttps(url)) {
+ throw new Error('unexpected schema of person url: ' + url);
+ }
+
+ if (this.utilityService.punyHost(url) !== this.utilityService.punyHost(person.id)) {
+ throw new Error(`person url <> uri host mismatch: ${url} <> ${person.id}`);
+ }
}
// Create user
@@ -539,8 +549,18 @@ export class ApPersonService implements OnModuleInit {
const url = getOneApHrefNullable(person.url);
- if (url && !checkHttps(url)) {
- throw new Error('unexpected schema of person url: ' + url);
+ if (person.id == null) {
+ throw new Error('Refusing to update person without id');
+ }
+
+ if (url != null) {
+ if (!checkHttps(url)) {
+ throw new Error('unexpected schema of person url: ' + url);
+ }
+
+ if (this.utilityService.punyHost(url) !== this.utilityService.punyHost(person.id)) {
+ throw new Error(`person url <> uri host mismatch: ${url} <> ${person.id}`);
+ }
}
const updates = {