Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🖼️ fix: Permission Checks for Agent Avatar Uploads (#8412)
Samuel Pathd2e1ca4c4a26
diff --git a/api/server/controllers/agents/v1.js b/api/server/controllers/agents/v1.jsindex 4aa50521cf..c3c6167605 100644--- a/api/server/controllers/agents/v1.js+++ b/api/server/controllers/agents/v1.js@@ -391,6 +391,22 @@ const uploadAgentAvatarHandler = async (req, res) => {return res.status(400).json({ message: 'Agent ID is required' });}+ const isAdmin = req.user.role === SystemRoles.ADMIN;+ const existingAgent = await getAgent({ id: agent_id });++ if (!existingAgent) {+ return res.status(404).json({ error: 'Agent not found' });+ }++ const isAuthor = existingAgent.author.toString() === req.user.id;+ const hasEditPermission = existingAgent.isCollaborative || isAdmin || isAuthor;++ if (!hasEditPermission) {+ return res.status(403).json({+ error: 'You do not have permission to modify this non-collaborative agent',+ });+ }+const buffer = await fs.readFile(req.file.path);const fileStrategy = req.app.locals.fileStrategy;@@ -413,14 +429,7 @@ const uploadAgentAvatarHandler = async (req, res) => {source: fileStrategy,};- let _avatar;- try {- const agent = await getAgent({ id: agent_id });- _avatar = agent.avatar;- } catch (error) {- logger.error('[/:agent_id/avatar] Error fetching agent', error);- _avatar = {};- }+ let _avatar = existingAgent.avatar;if (_avatar && _avatar.source) {const { deleteFile } = getStrategyFunctions(_avatar.source);@@ -442,7 +451,7 @@ const uploadAgentAvatarHandler = async (req, res) => {};promises.push(- await updateAgent({ id: agent_id, author: req.user.id }, data, {+ await updateAgent({ id: agent_id }, data, {updatingUserId: req.user.id,}),);