Skip to content

Commit

Permalink
fix: sanitize IPFS URLs before processing
Browse files Browse the repository at this point in the history
- Ensure nameOp.nameValue is properly sanitized before IPFS processing
- Add HTML sanitization to prevent potential XSS attacks
- Only process values that start with 'ipfs://' after sanitization
  • Loading branch information
silkroadnomad committed Jan 18, 2025
1 parent 469ad40 commit cdf1a26
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion relay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libp2p-relay",
"version": "0.12.19",
"version": "0.12.22",
"private": true,
"scripts": {
"start:no-restart": "node src/relay.js",
Expand Down
2 changes: 1 addition & 1 deletion relay/src/pinner/nameOpsFileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class OrbitDBInterface {
const dbPath = './orbitdb/nameops';

// Clean up any stale lock files before opening
await this.cleanupLockFiles(dbPath);
await cleanupLockFiles(dbPath);

this.db = await this.orbitdb.open(dbName, {
type: 'documents',
Expand Down
8 changes: 4 additions & 4 deletions relay/src/pinner/scanBlockchainForNameOps.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async function processBlocks(
allowedAttributes: {},
});

if (sanitizedValue && !sanitizedValue.startsWith('ipfs://')) {
if (sanitizedValue && sanitizedValue.startsWith('ipfs://')) {
// Use the pinQueue for pinIpfsContent operation
// TODO: sanitize metadata before pinning
pinQueue.add(() =>
Expand Down Expand Up @@ -208,9 +208,9 @@ async function processBlocks(
})
);
} else {
logger.warn(
`Invalid or potentially harmful nameValue detected: ${nameOp.nameValue}`
);
// logger.warn(
// `Invalid or potentially harmful nameValue detected: ${nameOp.nameValue}`
// );
}
}
} else {
Expand Down

0 comments on commit cdf1a26

Please sign in to comment.