The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
Add sanitization for SVG uploads and enhance security headers for asset responses
JonCSykesa4702e48f976
diff --git a/docs/api/companies.md b/docs/api/companies.mdindex 4b92fe1e8d..efcac8c22c 100644--- a/docs/api/companies.md+++ b/docs/api/companies.md@@ -58,7 +58,7 @@ Valid image content types:- `image/jpg`- `image/webp`- `image/gif`-- `image/svg+xml` (`.svg`)+- `image/svg+xml`## Archive Companydiff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b9b5f3e0aa..053c76c560 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -19,7 +19,7 @@ importers:version: 5.9.3vitest:specifier: ^3.0.5- version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])+ version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])cli:dependencies:@@ -126,9 +126,6 @@ importers:specifier: ^1.1.1version: 1.1.1devDependencies:- '@types/node':- specifier: ^24.6.0- version: 24.12.0typescript:specifier: ^5.7.3version: 5.9.3@@ -191,7 +188,7 @@ importers:version: 5.9.3vitest:specifier: ^3.0.5- version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])+ version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])packages/shared:dependencies:@@ -234,10 +231,13 @@ importers:version: link:../packages/sharedbetter-auth:specifier: 1.4.18- version: 1.4.18([email protected])([email protected](@electric-sql/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))+ version: 1.4.18([email protected])([email protected](@electric-sql/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected]))detect-port:specifier: ^2.1.0version: 2.1.0+ dompurify:+ specifier: ^3.3.2+ version: 3.3.2dotenv:specifier: ^17.0.1version: 17.3.1@@ -250,6 +250,9 @@ importers:express:specifier: ^5.1.0version: 5.2.1+ jsdom:+ specifier: ^28.1.0+ version: 28.1.0(@noble/[email protected])multer:specifier: ^2.0.2version: 2.0.2@@ -278,6 +281,9 @@ importers:'@types/express-serve-static-core':specifier: ^5.0.0version: 5.1.1+ '@types/jsdom':+ specifier: ^28.0.0+ version: 28.0.0'@types/multer':specifier: ^2.0.0version: 2.0.0@@ -304,7 +310,7 @@ importers:vitest:specifier: ^3.0.5- version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])+ version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])ui:dependencies:@@ -410,10 +416,23 @@ importers:vitest:specifier: ^3.0.5- version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])+ version: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])packages:+ '@acemir/[email protected]':+ resolution: {integrity: sha512-ZnR3GSaH+/vJ0YlHau21FjfLYjMpYVIzTD8M8vIEQvIGxeOXyXdzCI140rrCY862p/C/BbzWsjc1dgnM9mkoTA==}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-2SZFvqMyvboVV1d15lMf7XiI3m7SDqXUuKaTymJYLN6dSGadqp+fVojqJlVoMlbZnlTmu3S0TLwLTJpvBMO1Aw==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-MvRz1nCqW0fsy8Qz4dnLIvhOlMzqDVBabZx6lH+YywFDdjXhMY37SmpV1XFX3JzG5GWHn63j6HX6QPr3lZXHvQ==}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==}+'@aws-crypto/[email protected]':resolution: {integrity: sha512-nLbCWqQNgUiwwtFsen1AdzAtvuLRsQS8rYgMuxCrdKf9kOssamGLuPwyTY9wyYblNr9+1XM8v6zoDTPPSIeANg==}engines: {node: '>=16.0.0'}@@ -689,6 +708,10 @@ packages:'@better-fetch/[email protected]':resolution: {integrity: sha512-/ImESw0sskqlVR94jB+5+Pxjf+xBwDZF/N5+y2/q4EqD7IARUTSpPfIo8uf39SYpCxyOCtbyYpUrZ3F/k0zT4A==}+ '@bramus/[email protected]':+ resolution: {integrity: sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==}+ hasBin: true+'@changesets/[email protected]':resolution: {integrity: sha512-yq8ML3YS7koKQ/9bk1PqO0HMzApIFNwjlwCnwFEXMzNe8NpzeeYYKCmnhWJGkN8g7E51MnWaSbqRcTcdIxUgnQ==}@@ -855,6 +878,37 @@ packages:react: ^16.8.0 || ^17 || ^18 || ^19react-dom: ^16.8.0 || ^17 || ^18 || ^19+ '@csstools/[email protected]':+ resolution: {integrity: sha512-LMGQLS9EuADloEFkcTBR3BwV/CGHV7zyDxVRtVDTwdI2Ca4it0CCVTT9wCkxSgokjE5Ho41hEPgb8OEUwoXr6Q==}+ engines: {node: '>=20.19.0'}++ '@csstools/[email protected]':+ resolution: {integrity: sha512-HJ26Z/vmsZQqs/o3a6bgKslXGFAungXGbinULZO3eMsOyNJHeBBZfup5FiZInOghgoM4Hwnmw+OgbJCNg1wwUQ==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-parser-algorithms': ^4.0.0+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-0GEfbBLmTFf0dJlpsNU7zwxRIH0/BGEMuXLTCvFYxuL1tNhqzTbtnFICyJLTNK4a+RechKP75e7w42ClXSnJQw==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-parser-algorithms': ^4.0.0+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-H4tuz2nhWgNKLt1inYpoVCfbJbMwX/lQKp3g69rrrIMIYlFD9+zTykOKhNR8uGrAmbS/kT9n6hTFkmDkxLgeTA==}++ '@csstools/[email protected]':+ resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==}+ engines: {node: '>=20.19.0'}+'@dnd-kit/[email protected]':resolution: {integrity: sha512-2P+YgaXF+gRsIihwwY1gCsQSYnu9Zyj2py8kY5fFvUM1qm2WA2u639R6YNVfU4GWr+ZM5mqEsfHZZLoRONbemw==}peerDependencies:@@ -1383,6 +1437,15 @@ packages:cpu: [x64]os: [win32]+ '@exodus/[email protected]':+ resolution: {integrity: sha512-UY0nlA+feH81UGSHv92sLEPLCeZFjXOuHhrIo0HQydScuQc8s0A7kL/UdgwgDq8g8ilksmuoF35YVTNphV2aBQ==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+ peerDependencies:+ '@noble/hashes': ^1.8.0 || ^2.0.0+ peerDependenciesMeta:+ '@noble/hashes':+ optional: true+'@floating-ui/[email protected]':resolution: {integrity: sha512-C3HlIdsBxszvm5McXlB8PeOEWfBhcGBTZGkGlWc2U0KFY5IwG5OQEuQ8rq52DZmcHDlPLd+YFBK+cZcytwIFWg==}@@ -2825,6 +2888,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==}+ '@types/[email protected]':+ resolution: {integrity: sha512-A8TBQQC/xAOojy9kM8E46cqT00sF0h7dWjV8t8BJhUi2rG6JRh7XXQo/oLoENuZIQEpXsxLccLCnknyQd7qssQ==}+'@types/[email protected]':resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}@@ -2875,6 +2941,12 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-8WzXq62EXFhJ7QsH3Ocb/iKQ/Ty9ZVWnVzoTKc9tyyFRRF3a74Tk2+TLFgaFFw364Ere+npzHKEJ6ga2LzIL7w==}+ '@types/[email protected]':+ resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==}++ '@types/[email protected]':+ resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}+'@types/[email protected]':resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==}@@ -2940,6 +3012,10 @@ packages:resolution: {integrity: sha512-XNAb/a6TCqou+TufU8/u11HCu9x1gYvOoxLwtlXgIqmkrYQADVv6ljyW2zwiPhHz9R1gItAWpuDrdJMmrOBFEA==}engines: {node: '>= 16.0.0'}+ resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}+ engines: {node: '>= 14'}+resolution: {integrity: sha512-vcZjxvvVoxTeR5XBNJB38oTu/7eDCZlwdz32N1eNgpyPF7j/Z7Idf+CUwQOkKKpJ7RJyjxgLHCM7vdIK0iCNMQ==}@@ -3070,6 +3146,9 @@ packages:resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==}engines: {node: '>=4'}+ resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}+resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==}engines: {node: '>=18'}@@ -3232,11 +3311,19 @@ packages:resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}engines: {node: '>= 8'}+ resolution: {integrity: sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==}+ engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}+resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==}engines: {node: '>=4'}hasBin: true+ resolution: {integrity: sha512-Fm5NvhYathRnXNVndkUsCCuR63DCLVVwGOOwQw782coXFi5HhkXdu289l59HlXZBawsyNccXfWRYvLzcDCdDig==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}@@ -3244,6 +3331,10 @@ packages:resolution: {integrity: sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==}engines: {node: '>=0.12'}+ resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==}@@ -3256,6 +3347,9 @@ packages:supports-color:optional: true+ resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}+resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}@@ -3320,6 +3414,10 @@ packages:resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==}engines: {node: '>=8'}+ resolution: {integrity: sha512-6obghkliLdmKa56xdbLOpUZ43pAR6xFy1uOrxBaIDjT+yaRuuybLjGS9eVBoSR/UPU5fq3OXClEHLJNGvbxKpQ==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==}engines: {node: '>=12'}@@ -3458,6 +3556,10 @@ packages:resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==}engines: {node: '>=8.6'}+ resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==}+ engines: {node: '>=0.12'}+resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}engines: {node: '>= 0.4'}@@ -3700,6 +3802,10 @@ packages:resolution: {integrity: sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==}+ resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==}@@ -3707,6 +3813,14 @@ packages:resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==}engines: {node: '>= 0.8'}+ resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==}+ engines: {node: '>= 14'}++ resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==}+ engines: {node: '>= 14'}+resolution: {integrity: sha512-tsYlhAYpjCKa//8rXZ9DqKEawhPoSytweBC2eNvcaDK+57RZLHGqNs3PZTQO6yekLFSuvA6AlnAfrw1uBvtb+Q==}hasBin: true@@ -3778,6 +3892,9 @@ packages:resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}engines: {node: '>=12'}+ resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}+resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==}@@ -3824,6 +3941,15 @@ packages:resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==}hasBin: true+ resolution: {integrity: sha512-0+MoQNYyr2rBHqO1xilltfDjV9G7ymYGlAUazgcDLQaUf8JDHbuGwsxN6U9qWaElZ4w1B2r7yEGIL3GdeW3Rug==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+ peerDependencies:+ canvas: ^3.0.0+ peerDependenciesMeta:+ canvas:+ optional: true+resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}engines: {node: '>=6'}@@ -3940,6 +4066,10 @@ packages:resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==}+ resolution: {integrity: sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==}+ engines: {node: 20 || >=22}+resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}@@ -4019,6 +4149,9 @@ packages:resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}+ resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==}+resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==}engines: {node: '>= 0.6'}@@ -4270,6 +4403,12 @@ packages:resolution: {integrity: sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==}+ resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==}++ resolution: {integrity: sha512-9m4m5GSgXjL4AjumKzq1Fgfp3Z8rsvjRNbnkVwfu2ImRqE5D0LnY2QfDen18FSY9C573YU5XxSapdHZTZ2WolA==}+resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}engines: {node: '>= 0.8'}@@ -4422,6 +4561,10 @@ packages:resolution: {integrity: sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==}+ resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}+ engines: {node: '>=6'}+resolution: {integrity: sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==}engines: {node: '>=0.6'}@@ -4567,6 +4710,10 @@ packages:resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}+ resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}+ engines: {node: '>=0.10.0'}+resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}engines: {node: '>=8'}@@ -4611,6 +4758,10 @@ packages:resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}+ resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}+ engines: {node: '>=v12.22.7'}+resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==}@@ -4766,6 +4917,9 @@ packages:resolution: {integrity: sha512-oK8WG9diS3DlhdUkcFn4tkNIiIbBx9lI2ClF8K+b2/m8Eyv47LSawxUzZQSNKUrVb2KsqeTDCcjAAVPYaSLVTA==}engines: {node: '>=14.18.0'}+ resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}+resolution: {integrity: sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg==}@@ -4808,6 +4962,13 @@ packages:resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==}engines: {node: '>=14.0.0'}+ resolution: {integrity: sha512-ZjCZK0rppSBu7rjHYDYsEaMOIbbT+nWF57hKkv4IUmZWBNrBWBOjIElc0mKRgLM8bm7x/BBlof6t2gi/Oq/Asw==}++ resolution: {integrity: sha512-keinCnPbwXEUG3ilrWQZU+CqcTTzHq9m2HhoUP2l7Xmi8l1LuijAXLpAJ5zRW+ifKTNscs4NdCkfkDCBYm352w==}+ hasBin: true+resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}engines: {node: '>=8.0'}@@ -4816,6 +4977,14 @@ packages:resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}engines: {node: '>=0.6'}+ resolution: {integrity: sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==}+ engines: {node: '>=16'}++ resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}@@ -4855,6 +5024,13 @@ packages:resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}+ resolution: {integrity: sha512-RKZvifiL60xdsIuC80UY0dq8Z7DbJUV8/l2hOVbyZAxBzEeQU4Z58+4ZzJ6WN2Lidi9KzT5EbiGX+PI/UGYuRw==}++ resolution: {integrity: sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg==}+ engines: {node: '>=20.18.1'}+resolution: {integrity: sha512-ynU0vsAXw0ir8roa+xPCUHmnJ5goc5BTM2Kuc3IJd8UwgaeRs7VSD5+eeaQL+xp1JtB92hu/Zy/Lgy7RZcr1pQ==}@@ -5052,6 +5228,22 @@ packages:resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==}+ resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}+ engines: {node: '>=18'}++ resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}+ engines: {node: '>=20'}++ resolution: {integrity: sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==}+ engines: {node: '>=20'}++ resolution: {integrity: sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}engines: {node: '>= 8'}@@ -5081,6 +5273,13 @@ packages:resolution: {integrity: sha512-g/eziiSUNBSsdDJtCLB8bdYEUMj4jR7AGeUo96p/3dTafgjHhpF4RiCFPiRILwjQoDXx5MqkBr4fwWtR3Ky4Wg==}engines: {node: '>=20'}+ resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}+ engines: {node: '>=18'}++ resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}+resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}engines: {node: '>=0.4'}@@ -5103,6 +5302,26 @@ packages:snapshots:+ '@acemir/[email protected]': {}++ '@asamuzakjp/[email protected]':+ dependencies:+ '@csstools/css-calc': 3.1.1(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-color-parser': 4.0.2(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0+ lru-cache: 11.2.6++ '@asamuzakjp/[email protected]':+ dependencies:+ '@asamuzakjp/nwsapi': 2.3.9+ bidi-js: 1.0.3+ css-tree: 3.2.1+ is-potential-custom-element-name: 1.0.1+ lru-cache: 11.2.6++ '@asamuzakjp/[email protected]': {}+'@aws-crypto/[email protected]':dependencies:'@aws-crypto/util': 5.2.0@@ -5731,6 +5950,10 @@ snapshots:'@better-fetch/[email protected]': {}+ '@bramus/[email protected]':+ dependencies:+ css-tree: 3.2.1+'@changesets/[email protected]':dependencies:'@changesets/config': 3.1.3@@ -6179,6 +6402,28 @@ snapshots:react-dom: 19.2.4([email protected])react-is: 17.0.2+ '@csstools/[email protected]': {}++ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':+ dependencies:+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0++ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':+ dependencies:+ '@csstools/color-helpers': 6.0.2+ '@csstools/css-calc': 3.1.1(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0++ '@csstools/[email protected](@csstools/[email protected])':+ dependencies:+ '@csstools/css-tokenizer': 4.0.0++ '@csstools/[email protected]': {}++ '@csstools/[email protected]': {}+'@dnd-kit/[email protected]([email protected])':dependencies:react: 19.2.4@@ -6465,6 +6710,10 @@ snapshots:'@esbuild/[email protected]':optional: true+ '@exodus/[email protected](@noble/[email protected])':+ optionalDependencies:+ '@noble/hashes': 2.0.1+'@floating-ui/[email protected]':dependencies:'@floating-ui/utils': 0.2.10@@ -8209,6 +8458,13 @@ snapshots:'@types/[email protected]': {}+ '@types/[email protected]':+ dependencies:+ '@types/node': 25.2.3+ '@types/tough-cookie': 4.0.5+ parse5: 7.3.0+ undici-types: 7.22.0+'@types/[email protected]':dependencies:'@types/unist': 3.0.3@@ -8268,6 +8524,11 @@ snapshots:'@types/methods': 1.1.4'@types/superagent': 8.1.9+ '@types/[email protected]': {}++ '@types/[email protected]':+ optional: true+'@types/[email protected]': {}'@types/[email protected]': {}@@ -8353,6 +8614,8 @@ snapshots:+ [email protected]: {}+@@ -8389,7 +8652,7 @@ snapshots:- [email protected]([email protected])([email protected](@electric-sql/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected]([email protected])([email protected](@electric-sql/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])):dependencies:'@better-auth/core': 1.4.18(@better-auth/[email protected])(@better-fetch/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/telemetry': 1.4.18(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))@@ -8409,7 +8672,7 @@ snapshots:pg: 8.18.0react: 19.2.4react-dom: 19.2.4([email protected])- vitest: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])+ vitest: 3.2.4(@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])dependencies:@@ -8424,6 +8687,10 @@ snapshots:dependencies:is-windows: 1.0.2+ dependencies:+ require-from-string: 2.0.2+dependencies:bytes: 3.1.2@@ -8587,8 +8854,20 @@ snapshots:shebang-command: 2.0.0which: 2.0.2+ dependencies:+ mdn-data: 2.27.1+ source-map-js: 1.2.1++ dependencies:+ '@asamuzakjp/css-color': 5.0.1+ '@csstools/css-syntax-patches-for-csstree': 1.1.0+ css-tree: 3.2.1+ lru-cache: 11.2.6+@@ -8596,12 +8875,21 @@ snapshots:es5-ext: 0.10.64type: 2.7.3+ [email protected](@noble/[email protected]):+ dependencies:+ whatwg-mimetype: 5.0.0+ whatwg-url: 16.0.1(@noble/[email protected])+ transitivePeerDependencies:+ - '@noble/hashes'+dependencies:ms: 2.1.3+ [email protected]: {}+dependencies:character-entities: 2.0.2@@ -8650,6 +8938,10 @@ snapshots:dependencies:path-type: 4.0.0+ optionalDependencies:+ '@types/trusted-types': 2.0.7+@@ -8723,6 +9015,8 @@ snapshots:ansi-colors: 4.1.3strip-ansi: 6.0.1+ [email protected]: {}+@@ -9092,6 +9386,12 @@ snapshots:+ [email protected](@noble/[email protected]):+ dependencies:+ '@exodus/bytes': 1.15.0(@noble/[email protected])+ transitivePeerDependencies:+ - '@noble/hashes'+@@ -9102,6 +9402,20 @@ snapshots:statuses: 2.0.2toidentifier: 1.0.1+ dependencies:+ agent-base: 7.1.4+ debug: 4.4.3+ transitivePeerDependencies:+ - supports-color++ dependencies:+ agent-base: 7.1.4+ debug: 4.4.3+ transitivePeerDependencies:+ - supports-color+@@ -9149,6 +9463,8 @@ snapshots:+ [email protected]: {}+@@ -9184,6 +9500,33 @@ snapshots:dependencies:argparse: 2.0.1+ [email protected](@noble/[email protected]):+ dependencies:+ '@acemir/cssom': 0.9.31+ '@asamuzakjp/dom-selector': 6.8.1+ '@bramus/specificity': 2.4.2+ '@exodus/bytes': 1.15.0(@noble/[email protected])+ cssstyle: 6.2.0+ data-urls: 7.0.0(@noble/[email protected])+ decimal.js: 10.6.0+ html-encoding-sniffer: 6.0.0(@noble/[email protected])+ http-proxy-agent: 7.0.2+ https-proxy-agent: 7.0.6+ is-potential-custom-element-name: 1.0.1+ parse5: 8.0.0+ saxes: 6.0.0+ symbol-tree: 3.2.4+ tough-cookie: 6.0.0+ undici: 7.22.0+ w3c-xmlserializer: 5.0.0+ webidl-conversions: 8.0.1+ whatwg-mimetype: 5.0.0+ whatwg-url: 16.0.1(@noble/[email protected])+ xml-name-validator: 5.0.0+ transitivePeerDependencies:+ - '@noble/hashes'+ - supports-color+@@ -9265,6 +9608,8 @@ snapshots:+ [email protected]: {}+dependencies:yallist: 3.1.1@@ -9475,6 +9820,8 @@ snapshots:dependencies:'@types/mdast': 4.0.4+ [email protected]: {}+@@ -9881,6 +10228,14 @@ snapshots:is-decimal: 2.0.1is-hexadecimal: 2.0.1+ dependencies:+ entities: 6.0.1++ dependencies:+ entities: 6.0.1+@@ -10034,6 +10389,8 @@ snapshots:end-of-stream: 1.4.5once: 1.4.0+ [email protected]: {}+dependencies:side-channel: 1.1.0@@ -10250,6 +10607,8 @@ snapshots:mdast-util-to-markdown: 2.1.2unified: 11.0.5+ [email protected]: {}+@@ -10315,6 +10674,10 @@ snapshots:+ dependencies:+ xmlchars: 2.2.0+@@ -10490,6 +10853,8 @@ snapshots:transitivePeerDependencies:- supports-color+ [email protected]: {}+@@ -10519,12 +10884,26 @@ snapshots:+ [email protected]: {}++ dependencies:+ tldts-core: 7.0.25+dependencies:is-number: 7.0.0+ dependencies:+ tldts: 7.0.25++ dependencies:+ punycode: 2.3.1+@@ -10559,6 +10938,10 @@ snapshots:+ [email protected]: {}++ [email protected]: {}+dependencies:diff: 5.2.2@@ -10752,7 +11135,7 @@ snapshots:lightningcss: 1.30.2tsx: 4.21.0- [email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]):+ [email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected]):dependencies:'@types/chai': 5.2.3'@vitest/expect': 3.2.4@@ -10780,6 +11163,7 @@ snapshots:optionalDependencies:'@types/debug': 4.1.12'@types/node': 24.12.0+ jsdom: 28.1.0(@noble/[email protected])transitivePeerDependencies:- jiti- less@@ -10794,7 +11178,7 @@ snapshots:- tsx- yaml- [email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]):+ [email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected]):dependencies:'@types/chai': 5.2.3'@vitest/expect': 3.2.4@@ -10822,6 +11206,7 @@ snapshots:optionalDependencies:'@types/debug': 4.1.12'@types/node': 25.2.3+ jsdom: 28.1.0(@noble/[email protected])transitivePeerDependencies:- jiti- less@@ -10838,6 +11223,22 @@ snapshots:+ dependencies:+ xml-name-validator: 5.0.0++ [email protected]: {}++ [email protected]: {}++ [email protected](@noble/[email protected]):+ dependencies:+ '@exodus/bytes': 1.15.0(@noble/[email protected])+ tr46: 6.0.0+ webidl-conversions: 8.0.1+ transitivePeerDependencies:+ - '@noble/hashes'+dependencies:isexe: 2.0.0@@ -10856,6 +11257,10 @@ snapshots:is-wsl: 3.1.1powershell-utils: 0.1.0+ [email protected]: {}++ [email protected]: {}+diff --git a/server/package.json b/server/package.jsonindex 2e47011152..cf68566bac 100644--- a/server/package.json+++ b/server/package.json@@ -34,17 +34,19 @@"@paperclipai/adapter-claude-local": "workspace:*","@paperclipai/adapter-codex-local": "workspace:*","@paperclipai/adapter-cursor-local": "workspace:*",- "@paperclipai/adapter-opencode-local": "workspace:*","@paperclipai/adapter-openclaw": "workspace:*",+ "@paperclipai/adapter-opencode-local": "workspace:*","@paperclipai/adapter-utils": "workspace:*","@paperclipai/db": "workspace:*","@paperclipai/shared": "workspace:*","better-auth": "1.4.18","detect-port": "^2.1.0",+ "dompurify": "^3.3.2","dotenv": "^17.0.1","drizzle-orm": "^0.38.4","embedded-postgres": "^18.1.0-beta.16","express": "^5.1.0",+ "jsdom": "^28.1.0","multer": "^2.0.2","open": "^11.0.0","pino": "^9.6.0",@@ -56,6 +58,7 @@"devDependencies": {"@types/express": "^5.0.0","@types/express-serve-static-core": "^5.0.0",+ "@types/jsdom": "^28.0.0","@types/multer": "^2.0.0","@types/node": "^24.6.0","@types/supertest": "^6.0.2",diff --git a/server/src/__tests__/assets.test.ts b/server/src/__tests__/assets.test.tsindex eb58e24ab2..85ddf56a00 100644--- a/server/src/__tests__/assets.test.ts+++ b/server/src/__tests__/assets.test.ts@@ -25,10 +25,10 @@ function createAsset() {companyId: "company-1",provider: "local",objectKey: "assets/abc",- contentType: "image/svg+xml",+ contentType: "image/png",byteSize: 40,sha256: "sha256-sample",- originalFilename: "logo.svg",+ originalFilename: "logo.png",createdByAgentId: null,createdByUserId: "user-1",createdAt: now,@@ -36,7 +36,7 @@ function createAsset() {};}-function createStorageService(contentType = "image/svg+xml"): StorageService {+function createStorageService(contentType = "image/png"): StorageService {const putFile: StorageService["putFile"] = vi.fn(async (input: {companyId: string;namespace: string;@@ -84,29 +84,63 @@ describe("POST /api/companies/:companyId/assets/images", () => {logActivityMock.mockReset();});- it("accepts SVG image uploads and returns an asset path", async () => {- const svg = createStorageService("image/svg+xml");- const app = createApp(svg);+ it("accepts PNG image uploads and returns an asset path", async () => {+ const png = createStorageService("image/png");+ const app = createApp(png);createAssetMock.mockResolvedValue(createAsset());const res = await request(app).post("/api/companies/company-1/assets/images").field("namespace", "companies")- .attach("file", Buffer.from("<svg xmlns='http://www.w3.org/2000/svg'></svg>"), "logo.svg");+ .attach("file", Buffer.from("png"), "logo.png");expect(res.status).toBe(201);expect(res.body.contentPath).toBe("/api/assets/asset-1/content");expect(createAssetMock).toHaveBeenCalledTimes(1);- expect(svg.putFile).toHaveBeenCalledWith({+ expect(png.putFile).toHaveBeenCalledWith({companyId: "company-1",namespace: "assets/companies",- originalFilename: "logo.svg",- contentType: "image/svg+xml",+ originalFilename: "logo.png",+ contentType: "image/png",body: expect.any(Buffer),});});+ it("sanitizes SVG image uploads before storing them", async () => {+ const svg = createStorageService("image/svg+xml");+ const app = createApp(svg);++ createAssetMock.mockResolvedValue({+ ...createAsset(),+ contentType: "image/svg+xml",+ originalFilename: "logo.svg",+ });++ const res = await request(app)+ .post("/api/companies/company-1/assets/images")+ .field("namespace", "companies")+ .attach(+ "file",+ Buffer.from(+ "<svg xmlns='http://www.w3.org/2000/svg' onload='alert(1)'><script>alert(1)</script><a href='https://evil.example/'><circle cx='12' cy='12' r='10'/></a></svg>",+ ),+ "logo.svg",+ );++ expect(res.status).toBe(201);+ expect(svg.putFile).toHaveBeenCalledTimes(1);+ const stored = (svg.putFile as ReturnType<typeof vi.fn>).mock.calls[0]?.[0];+ expect(stored.contentType).toBe("image/svg+xml");+ expect(stored.originalFilename).toBe("logo.svg");+ const body = stored.body.toString("utf8");+ expect(body).toContain("<svg");+ expect(body).toContain("<circle");+ expect(body).not.toContain("<script");+ expect(body).not.toContain("onload=");+ expect(body).not.toContain("https://evil.example/");+ });+it("rejects files larger than 100 KB", async () => {const app = createApp(createStorageService());createAssetMock.mockResolvedValue(createAsset());@@ -154,4 +188,18 @@ describe("POST /api/companies/:companyId/assets/images", () => {expect(res.body.error).toBe("Unsupported image type: text/plain");expect(createAssetMock).not.toHaveBeenCalled();});++ it("rejects SVG image uploads that cannot be sanitized", async () => {+ const app = createApp(createStorageService("image/svg+xml"));+ createAssetMock.mockResolvedValue(createAsset());++ const res = await request(app)+ .post("/api/companies/company-1/assets/images")+ .field("namespace", "companies")+ .attach("file", Buffer.from("not actually svg"), "logo.svg");++ expect(res.status).toBe(422);+ expect(res.body.error).toBe("SVG could not be sanitized");+ expect(createAssetMock).not.toHaveBeenCalled();+ });});diff --git a/server/src/routes/assets.ts b/server/src/routes/assets.tsindex 0b1b81cb7c..7af319e05f 100644--- a/server/src/routes/assets.ts+++ b/server/src/routes/assets.ts@@ -1,5 +1,7 @@import { Router, type Request, type Response } from "express";import multer from "multer";+import createDOMPurify from "dompurify";+import { JSDOM } from "jsdom";import type { Db } from "@paperclipai/db";import { createAssetImageMetadataSchema } from "@paperclipai/shared";import type { StorageService } from "../storage/types.js";@@ -8,15 +10,80 @@ import { assertCompanyAccess, getActorInfo } from "./authz.js";const MAX_ASSET_IMAGE_BYTES = Number(process.env.PAPERCLIP_ATTACHMENT_MAX_BYTES) || 10 * 1024 * 1024;const MAX_COMPANY_LOGO_BYTES = 100 * 1024;+const SVG_CONTENT_TYPE = "image/svg+xml";const ALLOWED_IMAGE_CONTENT_TYPES = new Set(["image/png","image/jpeg","image/jpg","image/webp","image/gif",- "image/svg+xml",+ SVG_CONTENT_TYPE,]);+function sanitizeSvgBuffer(input: Buffer): Buffer | null {+ const raw = input.toString("utf8").trim();+ if (!raw) return null;++ const baseDom = new JSDOM("");+ const domPurify = createDOMPurify(+ baseDom.window as unknown as Parameters<typeof createDOMPurify>[0],+ );+ domPurify.addHook("uponSanitizeAttribute", (_node, data) => {+ const attrName = data.attrName.toLowerCase();+ const attrValue = (data.attrValue ?? "").trim();++ if (attrName.startsWith("on")) {+ data.keepAttr = false;+ return;+ }++ if ((attrName === "href" || attrName === "xlink:href") && attrValue && !attrValue.startsWith("#")) {+ data.keepAttr = false;+ }+ });++ let parsedDom: JSDOM | null = null;+ try {+ const sanitized = domPurify.sanitize(raw, {+ USE_PROFILES: { svg: true, svgFilters: true, html: false },+ FORBID_TAGS: ["script", "foreignObject"],+ FORBID_CONTENTS: ["script", "foreignObject"],+ RETURN_TRUSTED_TYPE: false,+ });++ parsedDom = new JSDOM(sanitized, { contentType: SVG_CONTENT_TYPE });+ const document = parsedDom.window.document;+ const root = document.documentElement;+ if (!root || root.tagName.toLowerCase() !== "svg") return null;++ for (const el of Array.from(root.querySelectorAll("script, foreignObject"))) {+ el.remove();+ }+ for (const el of Array.from(root.querySelectorAll("*"))) {+ for (const attr of Array.from(el.attributes)) {+ const attrName = attr.name.toLowerCase();+ const attrValue = attr.value.trim();+ if (attrName.startsWith("on")) {+ el.removeAttribute(attr.name);+ continue;+ }+ if ((attrName === "href" || attrName === "xlink:href") && attrValue && !attrValue.startsWith("#")) {+ el.removeAttribute(attr.name);+ }+ }+ }++ const output = root.outerHTML.trim();+ if (!output || !/^<svg[\s>]/i.test(output)) return null;+ return Buffer.from(output, "utf8");+ } catch {+ return null;+ } finally {+ parsedDom?.window.close();+ baseDom.window.close();+ }+}+export function assetRoutes(db: Db, storage: StorageService) {const router = Router();const svc = assetService(db);@@ -58,12 +125,21 @@ export function assetRoutes(db: Db, storage: StorageService) {return;}- const contentType = (file.mimetype || "").toLowerCase();+ let contentType = (file.mimetype || "").toLowerCase();if (!ALLOWED_IMAGE_CONTENT_TYPES.has(contentType)) {res.status(422).json({ error: `Unsupported image type: ${contentType || "unknown"}` });return;}- if (file.buffer.length <= 0) {+ let fileBody = file.buffer;+ if (contentType === SVG_CONTENT_TYPE) {+ const sanitized = sanitizeSvgBuffer(file.buffer);+ if (!sanitized || sanitized.length <= 0) {+ res.status(422).json({ error: "SVG could not be sanitized" });+ return;+ }+ fileBody = sanitized;+ }+ if (fileBody.length <= 0) {res.status(422).json({ error: "Image is empty" });return;}@@ -76,7 +152,7 @@ export function assetRoutes(db: Db, storage: StorageService) {const namespaceSuffix = parsedMeta.data.namespace ?? "general";const isCompanyLogoNamespace = namespaceSuffix === "companies" || namespaceSuffix.startsWith("companies/");- if (isCompanyLogoNamespace && file.buffer.length > MAX_COMPANY_LOGO_BYTES) {+ if (isCompanyLogoNamespace && fileBody.length > MAX_COMPANY_LOGO_BYTES) {res.status(422).json({ error: `Image exceeds ${MAX_COMPANY_LOGO_BYTES} bytes` });return;}@@ -87,7 +163,7 @@ export function assetRoutes(db: Db, storage: StorageService) {namespace: `assets/${namespaceSuffix}`,originalFilename: file.originalname || null,contentType,- body: file.buffer,+ body: fileBody,});const asset = await svc.create(companyId, {@@ -144,9 +220,14 @@ export function assetRoutes(db: Db, storage: StorageService) {assertCompanyAccess(req, asset.companyId);const object = await storage.getObject(asset.companyId, asset.objectKey);- res.setHeader("Content-Type", asset.contentType || object.contentType || "application/octet-stream");+ const responseContentType = asset.contentType || object.contentType || "application/octet-stream";+ res.setHeader("Content-Type", responseContentType);res.setHeader("Content-Length", String(asset.byteSize || object.contentLength || 0));res.setHeader("Cache-Control", "private, max-age=60");+ res.setHeader("X-Content-Type-Options", "nosniff");+ if (responseContentType === SVG_CONTENT_TYPE) {+ res.setHeader("Content-Security-Policy", "sandbox; default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'");+ }const filename = asset.originalFilename ?? "asset";res.setHeader("Content-Disposition", `inline; filename=\"${filename.replaceAll("\"", "")}\"`);diff --git a/ui/src/pages/CompanySettings.tsx b/ui/src/pages/CompanySettings.tsxindex 8d68fcff94..cf174c9d81 100644--- a/ui/src/pages/CompanySettings.tsx+++ b/ui/src/pages/CompanySettings.tsx@@ -278,12 +278,12 @@ export function CompanySettings() {<div className="flex-1 space-y-3"><Fieldlabel="Logo"- hint="Upload a logo image to replace the generated icon. Maximum size: 100 KB."+ hint="Upload a PNG, JPEG, WEBP, GIF, or SVG logo image. Maximum size: 100 KB."><div className="space-y-2"><inputtype="file"- accept="image/*,image/svg+xml"+ accept="image/png,image/jpeg,image/webp,image/gif,image/svg+xml"onChange={handleLogoFileChange}className="w-full rounded-md border border-border bg-transparent px-2.5 py-1.5 text-sm outline-none file:mr-4 file:rounded-md file:border-0 file:bg-muted file:px-2.5 file:py-1 file:text-xs"/>