diff options
| author | Laura Hausmann <laura@hausmann.dev> | 2024-10-24 05:11:16 +0200 |
|---|---|---|
| committer | Julia Johannesen <julia@insertdomain.name> | 2024-11-20 19:17:24 -0500 |
| commit | b74e2e91674ee56ef0b835daa31f5a72d02ab37d (patch) | |
| tree | d5de1b87934d7160348211ee764b398d49a4f578 /packages/backend/src | |
| parent | fix: primitive 15: improper same-origin validation for note uri and url (diff) | |
| download | sharkey-b74e2e91674ee56ef0b835daa31f5a72d02ab37d.tar.gz sharkey-b74e2e91674ee56ef0b835daa31f5a72d02ab37d.tar.bz2 sharkey-b74e2e91674ee56ef0b835daa31f5a72d02ab37d.zip | |
fix: primitive 16: improper same-origin validation for user uri and url
Diffstat (limited to 'packages/backend/src')
| -rw-r--r-- | packages/backend/src/core/activitypub/models/ApPersonService.ts | 28 |
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 = { |