GET 쿼리 문자열로 민감 정보 전달
Use of GET Request Method with Sensitive Query Strings
Last updated
Use of GET Request Method with Sensitive Query Strings
Last updated
const express = require("express");
const app = express();
// BAD: 비밀번호를 GET 쿼리에서 읽음
app.get("/signin", (req, res) => {
const user = req.query.user; // 비민감 예시
const password = req.query.password; // 취약: URL에 노출됨
// authenticate(user, password)
res.send("signed in");
});
app.listen(3000);const express = require("express");
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// GOOD: POST 본문에서 읽기
app.post("/signin", (req, res) => {
const { user, password } = req.body; // 민감값은 본문으로 전달
// authenticate(user, password)
res.send("signed in");
});
// 또는 토큰은 Authorization 헤더 사용
app.post("/api/data", (req, res) => {
const auth = req.get("Authorization"); // 예: 'Bearer <token>'
// verifyBearer(auth)
res.json({ ok: true });
});
app.listen(3000);