Skip to content

🛡️ fix: Sanitize Agent List Skill Scope#13122

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/fix-agent-list-skill-scope-leak
May 14, 2026
Merged

🛡️ fix: Sanitize Agent List Skill Scope#13122
danny-avila merged 1 commit into
devfrom
danny-avila/fix-agent-list-skill-scope-leak

Conversation

@danny-avila

Copy link
Copy Markdown
Owner

Summary

I fixed the agent list response so VIEW callers no longer receive raw skill-scope configuration, while preserving the $ skill popover behavior through a viewer-scoped effective skill response.

  • Added an opt-in includeSkillConfig projection flag to getListAgentsByAccess so raw skills and skills_enabled are excluded by default.
  • Sanitized /api/agents VIEW responses by intersecting configured skill IDs with the caller's VIEW-accessible skill IDs before returning any skill scope.
  • Preserved raw skill configuration for EDIT list callers so builder/edit flows can continue to read full agent configuration.
  • Added regression tests for the exact safe VIEW list field shape, viewer-accessible skill scope filtering, omitted inaccessible skill scope, EDIT raw config behavior, and the data-layer projection default.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Ran node --check api/server/controllers/agents/v1.js.
  • Ran node --check api/server/controllers/agents/v1.spec.js.
  • Ran git diff --check.
  • Targeted Jest was attempted but could not start in this worktree because local test dependencies are missing: api is missing cross-env, and packages/data-schemas is missing jest-junit.

Test Configuration:

  • Node.js: v20.19.5
  • npm: 10.8.2
  • Branch: danny-avila/fix-agent-list-skill-scope-leak

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI review requested due to automatic review settings May 14, 2026 12:42
@danny-avila danny-avila changed the title fix: Sanitize Agent List Skill Scope 🛡️ 🛡️ fix: Sanitize Agent List Skill Scope May 14, 2026
@danny-avila danny-avila changed the base branch from main to dev May 14, 2026 12:46
@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the /api/agents list response to prevent VIEW callers from receiving raw per-agent skill scope configuration, while still enabling the client to render the $ skill popover using a viewer-scoped “effective” skill scope.

Changes:

  • Adds an includeSkillConfig flag to getListAgentsByAccess to exclude skills / skills_enabled from the default projection unless explicitly requested.
  • Updates the agents list controller to sanitize skill scope for VIEW callers by intersecting configured skills with the caller’s VIEW-accessible skills.
  • Adds regression tests covering default projection behavior, safe VIEW list shape, VIEW skill filtering, and EDIT raw skill config behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/data-schemas/src/methods/agent.ts Adds opt-in projection control (includeSkillConfig) for returning raw skill configuration in list results.
packages/data-schemas/src/methods/agent.spec.ts Updates/extends data-layer tests to lock in the new default projection and the opt-in behavior.
api/server/controllers/agents/v1.js Sanitizes skill scope for VIEW list responses while allowing EDIT list callers to receive raw skill config.
api/server/controllers/agents/v1.spec.js Adds controller-level regression tests for safe VIEW list fields and skill scope filtering behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +62 to +94
const hasEditBit = (permission) => (permission & PermissionBits.EDIT) === PermissionBits.EDIT;

const sanitizeViewerSkillScope = (agent, accessibleSkillSet) => {
const skillScopeEnabled = agent.skills_enabled === true;
delete agent.skills_enabled;

if (!skillScopeEnabled) {
delete agent.skills;
return agent;
}

const configuredSkills = Array.isArray(agent.skills) ? agent.skills : [];
if (configuredSkills.length === 0) {
delete agent.skills;
if (accessibleSkillSet.size > 0) {
agent.skills_enabled = true;
}
return agent;
}

const visibleSkills = configuredSkills
.map((skillId) => String(skillId))
.filter((skillId) => accessibleSkillSet.has(skillId));

if (visibleSkills.length === 0) {
delete agent.skills;
return agent;
}

agent.skills = visibleSkills;
agent.skills_enabled = true;
return agent;
};
Comment on lines +966 to +975
let accessibleSkillSet = null;
if (!canReturnSkillConfig) {
const accessibleSkillIds = await findAccessibleResources({
userId,
role: req.user.role,
resourceType: ResourceType.SKILL,
requiredPermissions: PermissionBits.VIEW,
});
accessibleSkillSet = new Set(accessibleSkillIds.map((oid) => oid.toString()));
}
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13122 index is now live on the MCP server.
Deploy run

@danny-avila danny-avila marked this pull request as ready for review May 14, 2026 13:24
@danny-avila danny-avila merged commit 62da4c2 into dev May 14, 2026
16 checks passed
@danny-avila danny-avila deleted the danny-avila/fix-agent-list-skill-scope-leak branch May 14, 2026 13:27
fuuuzzy pushed a commit to fuuuzzy/LibreChat that referenced this pull request May 15, 2026
patricia2510 pushed a commit to lexaeon-org/libre-chat that referenced this pull request May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants