Node.js based forum software built for the modern web
fix: broken test, overly strict (and wrong) conditional, remove content-type check
Julian Lam3604452f747f
diff --git a/public/src/utils.common.js b/public/src/utils.common.jsindex 5052d109f7..0b462d3174 100644--- a/public/src/utils.common.js+++ b/public/src/utils.common.js@@ -364,7 +364,7 @@ const utils = {}// Basic PEM validationreturn pem.startsWith('-----BEGIN PUBLIC KEY-----') &&- pem.endsWith('-----END PUBLIC KEY-----') &&+ pem.trim().endsWith('-----END PUBLIC KEY-----') &&pem.includes('MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA');},diff --git a/src/activitypub/index.js b/src/activitypub/index.jsindex b405c4ce84..c4301b715e 100644--- a/src/activitypub/index.js+++ b/src/activitypub/index.js@@ -239,7 +239,7 @@ ActivityPub.fetchPublicKey = async (uri, ip) => {const lockId = `pubkey:${ip}`;const currentCount = publicKeyFetchRateLimit.get(lockId) || 0;const lockStatus = await db.incrObjectField('locks', lockId);- if (lockStatus >= 1 || currentCount >= 60) {+ if (lockStatus > 1 || currentCount >= 60) {winston.warn(`[activitypub/fetchPublicKey] Rate limit exceeded for IP ${ip}`);throw new Error('[[error:activitypub.rate-limited]]');}@@ -247,7 +247,7 @@ ActivityPub.fetchPublicKey = async (uri, ip) => {try {// Use requests.get with built-in SSRF protections// Set reasonable timeout and response size limit- const { body, headers } = await request.get(uri, {+ const { body } = await request.get(uri, {timeout: 5000, // 5 secondsheaders: {'accept': ActivityPub._constants.acceptableTypes.at(1),@@ -256,14 +256,6 @@ ActivityPub.fetchPublicKey = async (uri, ip) => {maxBodyLength: 1024 * 1024, // 1MB limit});- // Validate Content-Type header- if (- !headers['content-type'] ||- ActivityPub._constants.acceptableTypes.includes(headers['content-type'])- ) {- throw new Error('[[error:activitypub.invalid-content-type]]');- }-// Process response and cacheif (body.hasOwnProperty('publicKeyPem')) {// Validate public key