SECURITY·중요도 8·2026. 06. 13.·Dev.to

Encrypt your .env with AWS KMS: Secrets that never touch process.env

── KO ──────────────────

.env 파일을 AWS KMS로 암호화하여 프로세스 환경변수에 비밀이 저장되지 않도록 하는 방법을 설명합니다.

이 글에서는 .env 파일을 AWS KMS로 암호화하는 방법을 설명합니다. 최근 Next.js의 심각한 취약점으로 인해 모든 비밀이 process.env에 저장되어 공격자에게 노출될 위험이 있었던 사례를 공유합니다. 이를 해결하기 위해 @faizahmed/secret-keystore 패키지를 개발하였고, KMS Key ID만을 사용하도록 설계된 점을 강조합니다. 이러한 접근은 비밀 키가 아닌 KMS의 키 ID만을 다루기 때문에 보안 위험을 줄입니다.


── EN ──────────────────

Explains how to encrypt .env files with AWS KMS to prevent secrets from being stored in process.env.

This article explains how to encrypt .env files using AWS KMS. It shares a recent incident related to a critical vulnerability in Next.js that exposed secrets stored in process.env, leading to a significant security scare. In response, the author developed the @faizahmed/secret-keystore package, emphasizing the design decision to only handle the AWS KMS Key ID, which is not sensitive. This approach minimizes security risks by avoiding exposure of private keys.

원문 보기 →목록으로