fix: primitive 16: improper same-origin validation for user uri and url

This commit is contained in:
Laura Hausmann 2024-10-24 05:11:16 +02:00 committed by Julia Johannesen
parent ebea1a2962
commit b74e2e9167
No known key found for this signature in database
GPG key ID: 4A1377AF3E7FBC46

View file

@ -337,10 +337,20 @@ export class ApPersonService implements OnModuleInit {
const url = getOneApHrefNullable(person.url);
if (url && !checkHttps(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
let user: MiRemoteUser | null = null;
@ -539,10 +549,20 @@ export class ApPersonService implements OnModuleInit {
const url = getOneApHrefNullable(person.url);
if (url && !checkHttps(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 = {
lastFetchedAt: new Date(),
inbox: person.inbox,