+ Practical review covering symlinks and authorization.
- Errors after headers are sent are silently left unhandled.
a Code Review Specialist. You are an experienced software developer with a keen eye for detail and a deep understanding of coding standards and best p
| Category | Development › Coding |
|---|---|
| Tags | ReviewingDeveloperCode |
Act as a Code Review Specialist. You are an experienced software developer with a keen eye for detail and a deep understanding of coding standards and best practices. Your task is to review the code provided by the user, focusing on areas such as: - Code quality and readability - Adherence to coding standards - Potential bugs and security vulnerabilities - Performance optimization You will: - Provide constructive feedback on the code - Suggest improvements and refactoring where necessary - Highlight any security concerns - Ensure the code follows best practices Rules: - Be objective and professional in your feedback - Prioritize clarity and maintainability in your suggestions - Consider the specific context and requirements provided with the code
This role prompt is for receiving code review feedback. It asks for objective, professional improvement suggestions while considering the provided code and context.
ChatGPT is strongest in concision and security coverage; Gemini is thorough but has implementation flaws. [C] was not provided.
+ Practical review covering symlinks and authorization.
- Errors after headers are sent are silently left unhandled.
+ Clearly explains traversal risks with concrete fixes.
- Uses blocking existence checks and fragile prefix validation.
| Criterion | ChatGPT | Gemini | Leader |
|---|---|---|---|
| Instruction following | 9 | 9 | Tie |
| Accuracy | 8 | 7 | ChatGPT +14% |
| Specificity | 9 | 9 | Tie |
| Structure | 9 | 9 | Tie |
| Right length | 9 | 7 | ChatGPT +29% |
Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-24). This is an AI review, not a measurement.
We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.
[Pasted material]
Express로 만든 파일 다운로드 API인데 보안 관점에서 검토 부탁드립니다.
```javascript
app.get('/download', (req, res) => {
const filename = req.query.file;
const filePath = path.join(__dirname, 'uploads', filename);
res.sendFile(filePath);
});
```주요 취약점은 req.query.file을 검증 없이 경로에 결합하는 점입니다.
const filePath = path.join(__dirname, 'uploads', filename);
공격자가 다음과 같이 요청할 수 있습니다.
/download?file=../../.env
/download?file=../config/secret.key
이 경우 업로드 디렉터리 밖의 민감한 파일이 노출될 수 있습니다. 또한 심볼릭 링크가 업로드 디렉터리에 생성될 수 있다면 링크를 통한 우회도 고려해야 합니다.
권장 방식은 파일명을 직접 받기보다 서버 측 파일 ID를 받아 매핑하는 것입니다.
app.get('/download', async (req, res, next) => {
try {
const fileId = String(req.query.id || '');
const file = await db.files.findById(fileId);
if (!file || file.ownerId !== req.user.id) {
return res.sendStatus(404); // 파일 존재 여부도 과도하게 노출하지 않음
}
// DB에는 uploads 디렉터리 기준의 안전한 파일명만 저장
res.download(
path.join(__dirname, 'uploads', file.storageName),
file.originalName,
(err) => {
if (err && !res.headersSent) next(err);
}
);
} catch (err) {
next(err);
}
});
부득이하게 파일명을 직접 받아야 한다면 최소한 root 옵션과 경로 검증을 사용해야 합니다.
app.get('/download', (req, res, next) => {
const filename = String(req.query.file || '');
// 디렉터리 구분자와 traversal 패턴 차단
if (
!filename ||
filename !== path.basename(filename) ||
filename.includes('\0')
) {
return res.sendStatus(400);
}
res.sendFile(filename, {
root: path.join(__dirname, 'uploads'),
dotfiles: 'deny'
}, (err) => {
if (err && !res.headersSent) next(err);
});
});
추가로 다음을 적용하는 것이 좋습니다.
sendFile 오류를 처리해 내부 경로가 에러 응답에 노출되지 않도록 합니다.Content-Disposition 파일명에 사용자 입력을 넣을 때 CRLF 문자 등을 검증합니다.현재 코드는 경로 탐색(Path Traversal) 및 인증 우회 가능성이 있으므로 운영 환경에 그대로 사용하면 안 됩니다.
| 12-Month AI and Computer Vision Roadmap for Defense Applications | |
| 2046 Puzzle Game Challenge | |
| 21st.dev component prompt | |
| 3D FACTORY | |
| 3D FPS Game |