sanitize agent sent file names to prevent path traversal
This commit is contained in:
@@ -372,6 +372,11 @@ export function readOutboxFiles(
|
|||||||
if (!fs.existsSync(outboxDir)) return undefined;
|
if (!fs.existsSync(outboxDir)) return undefined;
|
||||||
const files: OutboundFile[] = [];
|
const files: OutboundFile[] = [];
|
||||||
for (const filename of filenames) {
|
for (const filename of filenames) {
|
||||||
|
// Reject any name that isn't a bare basename before touching the filesystem.
|
||||||
|
if (!isSafeAttachmentName(filename)) {
|
||||||
|
log.warn('Refused unsafe outbox filename — would escape outbox', { messageId, filename });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const filePath = path.join(outboxDir, filename);
|
const filePath = path.join(outboxDir, filename);
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
files.push({ filename, data: fs.readFileSync(filePath) });
|
files.push({ filename, data: fs.readFileSync(filePath) });
|
||||||
|
|||||||
Reference in New Issue
Block a user