🔒 Security

OWASP

Open Web Application Security Project

A global non-profit community for web application security. Defines the most critical web vulnerabilities through the OWASP Top 10 and provides free open-source security tools such as ZAP and Dependency-Check, along with guidelines. Supports developers, security professionals, and organizations in developing secure software.

📖 Detailed Explanation

OWASP (Open Web Application Security Project) is a nonprofit foundation established by Mark Curphey in 2001, with the goal of improving software security. It is a community-driven project in which tens of thousands of security professionals, developers, and researchers around the world participate, and it makes all of its materials and tools freely available. OWASP's core philosophy is "security is everyone's responsibility," and it supports anyone in building secure software, regardless of company size or budget.

The OWASP Top 10 is the most widely known project, and it compiles the 10 most critical vulnerabilities in web applications. As of the 2021 version, it includes Broken Access Control, Cryptographic Failures, Injection, Insecure Design, and others. This list is updated every 3 to 4 years and is compiled based on real vulnerability data and surveys of security professionals. Many organizations have adopted the OWASP Top 10 as a baseline for security requirements.

In addition to the Top 10, OWASP runs a variety of other projects. OWASP ZAP (Zed Attack Proxy) is the most popular free web vulnerability scanner and supports automated security testing. OWASP Dependency-Check detects known vulnerabilities in a project's dependencies. OWASP ASVS (Application Security Verification Standard) provides a standard for verifying application security, and OWASP SAMM (Software Assurance Maturity Model) is a framework for assessing an organization's security maturity.

In modern software development, OWASP is an essential reference. Organizations integrate OWASP ZAP into their DevSecOps pipelines to perform automated security testing, and use OWASP Dependency-Check to detect vulnerable libraries. Compliance audits such as PCI-DSS and HIPAA often require addressing the OWASP Top 10 as well. The OWASP AI Security project for the security of AI/ML systems is also attracting new attention.

💻 Code Example

# OWASP ZAP (Zed Attack Proxy) - 웹 취약점 자동 스캔
# Docker를 사용한 ZAP 스캔 예제

# 1. 기본 스캔 (Baseline Scan) - 빠른 수동적 스캔
docker run -t owasp/zap2docker-stable zap-baseline.py \
    -t https://example.com \
    -r zap-report.html

# 2. 전체 스캔 (Full Scan) - 능동적 취약점 테스트 포함
docker run -t owasp/zap2docker-stable zap-full-scan.py \
    -t https://example.com \
    -r full-report.html \
    -a  # AJAX Spider 포함

# 3. API 스캔 - OpenAPI/Swagger 스펙 기반
docker run -t owasp/zap2docker-stable zap-api-scan.py \
    -t https://api.example.com/openapi.json \
    -f openapi \
    -r api-report.html

# 4. CI/CD 통합 예제 (GitHub Actions)
# .github/workflows/security.yml
# name: OWASP ZAP Security Scan
# on: [push]
# jobs:
#   zap_scan:
#     runs-on: ubuntu-latest
#     steps:
#       - name: ZAP Scan
#         uses: zaproxy/action-baseline@v0.7.0
#         with:
#           target: 'https://staging.example.com'
#           fail_action: true
#           rules_file_name: '.zap/rules.tsv'

# 5. ZAP Python API 활용 예제
# pip install python-owasp-zap-v2.4
from zapv2 import ZAPv2

zap = ZAPv2(proxies={'http': 'http://127.0.0.1:8080'})

# Spider로 사이트 크롤링
zap.spider.scan('https://example.com')
while int(zap.spider.status()) < 100:
    time.sleep(2)

# 능동적 스캔 시작
zap.ascan.scan('https://example.com')
while int(zap.ascan.status()) < 100:
    time.sleep(5)

# 결과 확인
alerts = zap.core.alerts()
for alert in alerts:
    print(f"[{alert['risk']}] {alert['name']}: {alert['url']}")
# OWASP Dependency-Check - 의존성 취약점 검사
# 알려진 취약점(CVE)이 있는 라이브러리 탐지

# 1. CLI 설치 및 실행
# macOS
brew install dependency-check

# 프로젝트 스캔
dependency-check --project "MyProject" \
    --scan /path/to/project \
    --format HTML \
    --out dependency-check-report.html

# 2. Maven 플러그인 (pom.xml)
# <plugin>
#     <groupId>org.owasp</groupId>
#     <artifactId>dependency-check-maven</artifactId>
#     <version>8.4.0</version>
#     <executions>
#         <execution>
#             <goals>
#                 <goal>check</goal>
#             </goals>
#         </execution>
#     </executions>
#     <configuration>
#         <failBuildOnCVSS>7</failBuildOnCVSS>
#     </configuration>
# </plugin>
mvn dependency-check:check

# 3. Gradle 플러그인 (build.gradle)
# plugins {
#     id "org.owasp.dependencycheck" version "8.4.0"
# }
# dependencyCheck {
#     failBuildOnCVSS = 7
#     suppressionFile = "dependency-check-suppressions.xml"
# }
./gradlew dependencyCheckAnalyze

# 4. npm/yarn 프로젝트 (Node.js)
# npm audit 대안으로 더 정확한 검사
dependency-check --project "NodeApp" \
    --scan ./node_modules \
    --scan ./package-lock.json \
    --enableExperimental

# 5. GitHub Actions 통합
# - name: OWASP Dependency Check
#   uses: dependency-check/Dependency-Check_Action@main
#   with:
#     project: 'MyProject'
#     path: '.'
#     format: 'HTML'
#     args: '--failOnCVSS 7'
// OWASP Top 10 취약점 예방 코드 예제 (Node.js/Express)

const express = require('express');
const helmet = require('helmet');
const rateLimit = require('express-rate-limit');
const { body, validationResult } = require('express-validator');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');

const app = express();

// A03:2021 - Injection 방지
// 1. 파라미터화된 쿼리 사용 (SQL Injection 방지)
const { Pool } = require('pg');
const pool = new Pool();

// 잘못된 예 (취약)
// const query = `SELECT * FROM users WHERE id = ${userId}`;

// 올바른 예 (안전)
async function getUserById(userId) {
    const result = await pool.query(
        'SELECT * FROM users WHERE id = $1',  // 파라미터화
        [userId]
    );
    return result.rows[0];
}

// A02:2021 - Cryptographic Failures 방지
// 2. 안전한 비밀번호 해싱
async function hashPassword(password) {
    const saltRounds = 12;  // 최소 10 이상 권장
    return await bcrypt.hash(password, saltRounds);
}

async function verifyPassword(password, hash) {
    return await bcrypt.compare(password, hash);
}

// A01:2021 - Broken Access Control 방지
// 3. 역할 기반 접근 제어
function authorize(requiredRole) {
    return (req, res, next) => {
        const userRole = req.user?.role;
        if (!userRole || !hasPermission(userRole, requiredRole)) {
            return res.status(403).json({ error: 'Forbidden' });
        }
        next();
    };
}

// A07:2021 - XSS 방지
// 4. Helmet으로 보안 헤더 설정
app.use(helmet({
    contentSecurityPolicy: {
        directives: {
            defaultSrc: ["'self'"],
            scriptSrc: ["'self'"],  // 인라인 스크립트 차단
            styleSrc: ["'self'", "'unsafe-inline'"],
            imgSrc: ["'self'", "data:", "https:"],
        },
    },
    xssFilter: true,
}));

// A04:2021 - Insecure Design 방지
// 5. Rate Limiting (무차별 대입 공격 방지)
const loginLimiter = rateLimit({
    windowMs: 15 * 60 * 1000,  // 15분
    max: 5,  // 최대 5번 시도
    message: { error: 'Too many login attempts. Try again later.' },
    standardHeaders: true,
});

app.post('/login', loginLimiter, async (req, res) => {
    // 로그인 로직
});

// A03:2021 - Injection 방지 (입력 검증)
// 6. express-validator로 입력 검증
app.post('/users',
    [
        body('email').isEmail().normalizeEmail(),
        body('username').isAlphanumeric().isLength({ min: 3, max: 20 }),
        body('password').isStrongPassword({
            minLength: 12,
            minLowercase: 1,
            minUppercase: 1,
            minNumbers: 1,
            minSymbols: 1
        }),
    ],
    (req, res) => {
        const errors = validationResult(req);
        if (!errors.isEmpty()) {
            return res.status(400).json({ errors: errors.array() });
        }
        // 사용자 생성 로직
    }
);

// A08:2021 - SSRF 방지
// 7. URL 화이트리스트 검증
const allowedHosts = ['api.trusted.com', 'cdn.trusted.com'];

function isAllowedUrl(url) {
    try {
        const parsed = new URL(url);
        return allowedHosts.includes(parsed.hostname);
    } catch {
        return false;
    }
}

app.post('/fetch-url', (req, res) => {
    if (!isAllowedUrl(req.body.url)) {
        return res.status(400).json({ error: 'URL not allowed' });
    }
    // URL 페치 로직
});

🗣️ Say It Like This in Practice

💬 In a Security Audit Preparation Meeting
"In this security audit, they will ask about our status on addressing the OWASP Top 10. Let's run a full scan of the staging environment with OWASP ZAP and check all services for vulnerable dependencies with Dependency-Check. We need to be especially thorough with A01 Broken Access Control and A03 Injection."
💬 In a code review
"This part is an OWASP A03 Injection vulnerability. You must not put user input directly into SQL queries. Use parameterized queries or the ORM's safe methods. The OWASP Cheat Sheet has secure coding guides for each language, so please refer to it."
💬 In Building a DevSecOps Pipeline
"Let's integrate OWASP tools into CI/CD. At the PR stage, we block vulnerable libraries with Dependency-Check, and after deploying to staging, we automatically run a ZAP API scan. Let's build a gate that blocks deployment at CVSS 7 or higher, so that high-risk vulnerabilities don't go out to production."

⚠️ Cautions & Best Practices

❌
The misconception that checking only the OWASP Top 10 is enough

The Top 10 is just the 10 most common vulnerabilities and does not cover all security threats. Use OWASP ASVS (Application Security Verification Standard) to perform more comprehensive security verification. The Top 10 is a starting point, not an end point.

❌
Blindly trusting automated tool results

OWASP ZAP and Dependency-Check only detect known vulnerability patterns. Business logic vulnerabilities, zero-days, and complex authentication bypasses require manual penetration testing. Automated tools are a supplementary measure, not a perfect solution.

❌
Ignoring or overreacting to false positives

Vulnerability scan results include false positives. You must not ignore all warnings, nor conversely overreact to every warning. Verify each vulnerability manually and manage suppression rules appropriately.

✅
OWASP Best Practices

Apply OWASP Secure Coding Practices from the development stage. Integrate ZAP and Dependency-Check into CI/CD to perform continuous security checks. Regularly check for OWASP Top 10 updates and conduct team training. It is also a good idea to use OWASP SAMM to measure your organization's security maturity and establish an improvement plan.

🔗 Related Terms

📚 Learn More