SA-SKL-CORS38 — CORS Misconfiguration
CORS Misconfiguration in MCP Skill Registry Skill Rating and Review Submission Endpoints
Skill ratings and reviews are the trust signal that buyers rely on when evaluating community MCP skills. CORS38 covers four patterns — credential-bearing CORS on the review listing endpoint reads unpublished draft reviews and reviewer identity; wildcard ACAO on the review submission endpoint lets any page inject fake reviews on behalf of the victim using the victim’s per-user quota; Origin reflection before ownership check on the “my review” endpoint creates a timing oracle that reveals whether a specific user has written a draft for any skill; credential-bearing CORS on the delete endpoint lets any origin delete any review using the victim’s admin session, silencing critical security findings without leaving an audit trail.
GET /api/skills/:id/reviews uses cors({origin:true,credentials:true}); any origin reads all reviews including unpublished drafts and reviewer identity (email, username, org) using victim session; fix: allowlist; requireSession; return only published reviews for public callersPOST /api/skills/:id/reviews has ACAO: *; any page submits a fake review on behalf of victim using victim’s session quota and exhausts one-review-per-user allowance; fix: remove wildcard; require session; CSRF token; one-review-per-user enforcement before writeGET /api/skills/:id/reviews/my reflects Origin before ownership check; timing oracle reveals whether victim has a draft review for any skill ID, enabling cross-user reviewer identification; fix: unified WHERE skill_id=$1 AND user_id=$2; auth before CORS emissionDELETE /api/skills/:id/reviews/:reviewId uses cors({origin:true,credentials:true}); any origin deletes any review using victim admin session; silences critical security findings cross-origin; fix: allowlist + requireRole('admin') + ownership check + audit logCORS38-001 — Credential-bearing CORS on review listing reads unpublished drafts and reviewer identity
The review listing endpoint GET /api/skills/:id/reviews returns all reviews for a given skill, filtered by status. For authenticated admin users, the response includes unpublished drafts awaiting moderation and the full reviewer identity including email address, username, and organization affiliation. The endpoint was assigned cors({origin:true,credentials:true}) to support embedding review summaries in partner marketplace portals.
// CORS38-001 — VULNERABLE
// cors({origin:true,credentials:true}) — any origin reads draft reviews and reviewer identity.
router.get('/:id/reviews',
cors({ origin: true, credentials: true }), // VULNERABLE
requireSession,
async (req, res) => {
const reviews = await db.reviews.findBySkillId(req.params.id, {
includeUnpublished: true, // ← drafts visible to admins
includeReviewerDetails: true, // ← reviewer email and org
});
res.json(reviews);
}
);
// CORS38-001 — FIXED
// 1. Set-based allowlist at router level.
// 2. Only return published reviews to non-admin callers.
// 3. Never return reviewer email to non-admin; return only reviewer handle.
const ALLOWED_ORIGINS = new Set([
'https://app.skillaudit.dev',
'https://skillaudit.dev',
'https://partner-marketplace.example.com',
]);
router.use(cors({
origin: (o, cb) => ALLOWED_ORIGINS.has(o) || !o ? cb(null, true) : cb(new Error('CORS')),
credentials: true,
}));
router.get('/:id/reviews', requireSession, async (req, res) => {
const isAdmin = req.session.role === 'admin';
const reviews = await db.reviews.findBySkillId(req.params.id, {
includeUnpublished: isAdmin,
includeReviewerDetails: false, // never return reviewer email
});
res.json(reviews);
});
CORS38-002 — Wildcard ACAO on review submission lets any page inject fake reviews
The review submission endpoint POST /api/skills/:id/reviews was given ACAO: * to support lightweight review widgets embeddable on external skill documentation pages. Because the endpoint performs a mutation using session context, the wildcard creates a request-forgery vector: any page the victim visits can submit a review on their behalf, using up their one-review-per-skill allowance and injecting content they did not write.
// CORS38-002 — VULNERABLE
// ACAO:* on a mutating endpoint — any page submits a fake review via victim session.
router.post('/:id/reviews', async (req, res) => {
res.set('Access-Control-Allow-Origin', '*'); // VULNERABLE
const session = req.session;
if (!session) return res.status(401).json({ error: 'Unauthenticated' });
// Checks one-review-per-user AFTER already accepting the request
const existing = await db.reviews.findByUserAndSkill(session.userId, req.params.id);
if (existing) return res.status(409).json({ error: 'Already reviewed' });
await db.reviews.create({
skillId: req.params.id,
userId: session.userId,
rating: req.body.rating,
content: req.body.content,
status: 'pending',
});
res.status(201).json({ created: true });
});
// CORS38-002 — FIXED
// 1. Remove ACAO:* — allowlist at router level handles CORS.
// 2. Require session (already present) + CSRF token.
// 3. One-review-per-user check before any write.
router.post('/:id/reviews', requireSession, verifyCsrfToken, async (req, res) => {
// Check quota before write — consistent timing regardless of outcome
const existing = await db.reviews.findByUserAndSkill(req.session.userId, req.params.id);
if (existing) return res.status(409).json({ error: 'Already reviewed' });
const { rating, content } = req.body;
if (typeof rating !== 'number' || rating < 1 || rating > 5)
return res.status(400).json({ error: 'Invalid rating' });
await db.reviews.create({
skillId: req.params.id,
userId: req.session.userId,
rating,
content: content?.slice(0, 2000) ?? '',
status: 'pending',
});
res.status(201).json({ created: true });
});
CORS38-003 — Origin reflection before ownership check creates reviewer timing oracle
The “my review” endpoint GET /api/skills/:id/reviews/my returns the current user’s review for a given skill. Because CORS headers are emitted before the ownership-scoped query, the latency difference between “draft exists but belongs to another user” and “no review exists” creates a timing oracle. An attacker can probe which users have written (but not yet published) reviews for any skill, potentially targeting them for social engineering before the review goes public.
// CORS38-003 — VULNERABLE
// CORS emitted before ownership check — timing oracle via latency difference.
router.get('/:id/reviews/my',
cors({ origin: true, credentials: true }), // CORS before auth — timing observable
requireSession,
async (req, res) => {
const review = await db.reviews.findBySkillId(req.params.id); // scans all, then filters
if (!review) return res.status(404).json({ error: 'Not found' }); // fast path
if (review.userId !== req.session.userId)
return res.status(403).json({ error: 'Forbidden' }); // slow path — 3-4× latency
res.json(review);
}
);
// CORS38-003 — FIXED
// Single query with both skillId and userId — identical latency for not-found and wrong-owner.
router.get('/:id/reviews/my', requireSession, async (req, res) => {
const review = await db.reviews.findOne({
where: { skillId: req.params.id, userId: req.session.userId }, // ownership enforced at DB
});
if (!review) return res.status(404).json({ error: 'Not found' });
res.json(review);
});
CORS38-004 — Credential-bearing CORS on review deletion lets any origin delete any review via admin session
The review deletion endpoint DELETE /api/skills/:id/reviews/:reviewId uses cors({origin:true,credentials:true}) and requires admin role. Any page the victim admin visits can delete any review — including critical 1-star security-finding reviews — without admin interaction or audit trail.
// CORS38-004 — VULNERABLE
// cors({origin:true,credentials:true}) + admin-scoped delete — any origin silences reviews.
router.delete('/:id/reviews/:reviewId',
cors({ origin: true, credentials: true }), // VULNERABLE
requireSession,
requireRole('admin'),
async (req, res) => {
await db.reviews.deleteById(req.params.reviewId);
res.json({ deleted: true });
}
);
// CORS38-004 — FIXED
// 1. Allowlist CORS at router level.
// 2. requireRole('admin') already present — keep.
// 3. Soft-delete only: status='deleted', retains audit trail.
// 4. Audit log every deletion.
router.delete('/:id/reviews/:reviewId', requireSession, requireRole('admin'), async (req, res) => {
const review = await db.reviews.findOne({
where: { id: req.params.reviewId, skillId: req.params.id },
});
if (!review) return res.status(404).json({ error: 'Not found' });
await db.reviews.update(
{ status: 'deleted', deletedAt: new Date(), deletedBy: req.session.userId },
{ where: { id: req.params.reviewId } }
);
await auditLog.write({ action: 'review.delete', reviewId: req.params.reviewId,
adminId: req.session.userId, reason: req.body.reason });
res.json({ deleted: true });
});
Related findings
- SA-SKL-CORS37 — CORS misconfiguration in skill search and autocomplete suggestion endpoints
- SA-SKL-CORS36 — CORS misconfiguration in audit result caching and diff comparison endpoints
- Blog: CORS Misconfigurations in Skill Search and Autocomplete Endpoints