security illustration specific to the web topic
WEB SECURITY

Web Application Security

OWASP Top 10, common attacks, secure coding and defense strategies. Protect your web application from hacking.

30 minReading Time
8 EpisodesDetailed Guide
%43Attack Targeted Web
EPISODE 01

What is Web Security?

Web security is the practice of protecting web applications, websites, and web services against cyber attacks. Every application accessible over the Internet is a potential target.

Web Security Statistics

cyber attacks 43% targets web applications (Verizon DBIR 2024). every day 30.000 The website is being hacked. Average web breach cost $4.45 million. Vulnerabilities in web applications 94% at the application layer.

Scope of Web Security

Application Security

Code-level security. Closing vulnerabilities such as SQL injection, XSS, CSRF.

Server Security

Web server configuration. Apache, Nginx, IIS hardening.

Database Security

SQL injection protection, data encryption, access controls.

Network Security

Firewall, WAF, DDoS protection, TLS/SSL configuration.

Authentication

Strong passwords, MFA, session management, token security.

Compatibility

Compliance with regulations such as PCI-DSS, GDPR, KVKK.

Web Security vs Network Security

featureWeb SecurityNetwork Security
FocusApplication layer (Layer 7)Network layer (Layer 3-4)
targetWebsites, APIsServers, network devices
AttacksSQLi, XSS, CSRFDDoS, port scanning
defenseWAF, secure codingFirewall, IDS/IPS
testDAST, SAST, pentestVulnerability scan

💡 Basic Principle

web security layered defense requires. A single security measure is not enough. Code, server, network, and user training must work together.

EPISODE 02

OWASP Top 10 (2024)

OWASP (Open Web Application Security Project) updates the top 10 risks of web application security every 3-4 years. This list is the gold standard of web security.

🔴 Why is it important?

OWASP Top 10, worldwide Referenced by security experts, developers and auditors. Regulations such as PCI-DSS require compliance with this list.

OWASP Top 10 - 2024 Current List

#1

Broken Access Control

Users may perform actions beyond their authorization. Accessing the admin panel, seeing someone else's data, IDOR vulnerabilities.

Effect: Unauthorized data access, account takeover
Prevalence: 38.12% of tested applications
#2

Cryptographic Failures

Weak encryption or lack of encryption. Sensitive data remains exposed. Use of old algorithms (MD5, SHA1).

Effect: Data disclosure, identity theft
Prevalence: 44.31% of applications
#3

injection

SQL, NoSQL, OS, LDAP injection. User input is added directly to the query. The database can be compromised.

Effect: Complete data loss, system takeover
Prevalence: 19.09% apps
#4

Insecure Design

Lack of security at the architectural level. Threat modeling was not done. Security is not by design, but afterthought.

Effect: Basic design mistakes
Prevalence: New category (2021)
#5

Security Misconfiguration

Misconfiguration. Default passwords, unnecessary services, detailed error messages, open ports.

Effect: Easily exploitable vulnerabilities
Prevalence: 90.19% of applications
#6

Vulnerable and Outdated Components

Outdated libraries and frameworks. Known vulnerabilities are exploited. Dependency management is weak.

Effect: Exploitation of known vulnerabilities
Prevalence: 93.79% of applications
#7

Identification and Authentication Failures

Weak authentication. Breakable passwords, session management errors, credential stuffing.

Effect: account takeover
Prevalence: 15.19% apps
#8

Software and Data Integrity Failures

Do not accept code/data from untrusted sources. CI/CD pipeline security. Automatic update risks.

Effect: Malicious code injection
Prevalence: New category (2021)
#9

Security Logging and Monitoring Failures

Insufficient logging, lack of monitoring. Attacks cannot be detected. Forensic analysis cannot be performed.

Effect: Late detection, loss of evidence
Prevalence: 65.08% of applications
#10

Server-Side Request Forgery (SSRF)

The server requests malicious URLs. Internal network discovery, cloud metadata stealing.

Effect: Internal network access, data stealing
Prevalence: 4.51% apps

Mini Quiz: OWASP Top 10

Question 1/3

What is the most common risk in the OWASP Top 10?

EPISODE 03

Common Web Attacks

Let's examine the most common types of attacks against web applications in detail. Learn how each attack works and how to prevent it.

SQL Injection (SQLi)

SQL Injection

CRITICAL

Direct insertion of user input into the SQL query. An attacker can read, modify or delete the database.

BAD CODE:
$query = "SELECT * FROM users WHERE id = " . $_GET['id'];
// Attacker: ?id=1 OR 1=1 --
GOOD CODE:
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_GET['id']]);
Defense: Prepared statements, ORM usage, input validation, WAF

Cross-Site Scripting (XSS)

Cross-Site Scripting (XSS)

CRITICAL

Malicious JavaScript code is injected into the web page. The user's session can be stolen and his browser can be controlled.

Stored XSS: Bad code is saved in database, runs on every user
Reflected XSS: Bad code comes from URL, runs instantly
DOM-based XSS: Client-side JavaScript manipulation
BAD CODE:
echo "Merhaba " . $_GET['name'];
// Attacker: ?name=<script>alert('XSS')</script>
GOOD CODE:
echo "Merhaba " . htmlspecialchars($_GET['name'], ENT_QUOTES);
Defense: Output encoding, Content Security Policy (CSP), input validation

Cross-Site Request Forgery (CSRF)

CSRF

HIGH

Malicious requests are sent while the user is unaware. The fake form is submitted while the user is logged in.

Attack Example: <img src="http://bank.com/transfer?to=attacker&amount=1000">
Defense: CSRF tokens, SameSite cookies, referer checking

Other Notable Attacks

File Inclusion

LFI/RFI: Reading or executing files to the server.

Defense: Whitelist, input validation

File Upload

Malicious file upload. Web shell injection.

Defense: File type check, sandbox

SSRF

The server makes a request to the internal network. Cloud metadata stealing.

Defense: URL whitelist, network segmentation

IDOR

Unauthorized object reference. Access to someone else's data.

Defense: Authorization control, access control

⚠️ Critical Alert

Web attacks 80% It is caused by known vulnerabilities. The vast majority can be prevented with regular security testing and patch management.

EPISODE 04

Secure Coding Practices

Secure coding is the foundation of your web application. The OWASP Secure Coding Practices guide identifies best practices.

10 Golden Rules of Secure Coding

01

Input Validation

Verify all user input. Use a whitelist approach. Just accept the expected format.

02

Output Encoding

Encode the outputs. Use appropriate encoding according to HTML, JavaScript, SQL, URL context.

03

Parameterized Queries

Use prepared statements in SQL queries. Never do string concatenation.

04

Authentication

Strong password policy, MFA, session management. Hash the passwords with bcrypt/argon2.

05

authorization

Least privilege principle. Check authorization in every transaction. Beware of IDOR vulnerabilities.

06

Error Handling

Do not show detailed error messages to the user. Write it to the logs. Hide stack trace.

07

logging

Log important events. Maintain logs. Use for anomaly detection.

08

Data Protection

Encrypt sensitive data. Apply both transit (TLS) and rest (AES-256) encryption.

09

Dependency Management

Keep third-party libraries up to date. Track known vulnerabilities (Snyk, Dependabot).

10

Security Testing

Test regularly with SAST, DAST, pentest. Add security checks to the CI/CD pipeline.

Secure Coding Examples

UNSAFE

SQL Injection Vulnerability

// BAD: String concatenation
$query = "SELECT * FROM users 
WHERE username = '" . $username . "'";
$result = mysqli_query($conn, $query);
vulnerable to SQL injection
SAFE

Prepared Statement

// GOOD: Prepared statement
$stmt = $pdo->prepare(
"SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
safe
UNSAFE

XSS Vulnerability

// BAD: Direct output
echo "Merhaba " . $_GET['name'];
// Attacker: ?name=<script>...</script>
vulnerable to XSS
SAFE

Output Encoding

// GOOD: Output encoding
$name = htmlspecialchars(
$_GET['name'], ENT_QUOTES, 'UTF-8');
echo "Merhaba " . $name;
safe

✅ Best Practice

Secure coding it's just the beginning. Detect vulnerabilities with regular security tests (SAST, DAST, penetration testing).

EPISODE 05

HTTP Security Headers

HTTP security headers tell the browser about the application's security policies. It is a simple but effective layer of defense.

Mandatory Security Headings

Content-Security-Policy
Prevents XSS and code injection attacks. It limits resources.
default-src 'self'; script-src 'self'
Strict-Transport-Security
HSTS. Forces browsers to use HTTPS. Prevents SSL stripping attack.
max-age=31536000; includeSubDomains
X-Frame-Options
Prevents Clickjacking attacks. Restricts the use of iframes.
DENY veya SAMEORIGIN
X-Content-Type-Options
Prevents MIME type sniffing. Use nosniff value.
nosniff
Referrer-Policy
Checks referer information. Protects private URLs.
strict-origin-when-cross-origin
Permissions-Policy
Restricts browser features. Camera, microphone, location.
camera=(), microphone=()

Security Hood Testing Tools

SecurityHeaders.com

Free website security header scanner. Gives grades A-F.

Mozilla Observatory

Mozilla's security testing tool. Detailed report and recommendations.

SSL Labs

Qualys SSL Server Test. TLS configuration and certificate analysis.

⚠️ Important Note

Security headers alone is not enough. It should be used in conjunction with secure coding. If CSP is configured incorrectly it can break the site.

EPISODE 06

Web Application Security Testing

Security tests detect vulnerabilities before they go live. Different types of testing are applied at different stages.

Test Types

SAST (Static Analysis)

Statically analyzes the source code. Finds vulnerabilities while writing code. It is integrated into the CI/CD pipeline.

Tools: SonarQube, Semgrep, Checkmarx, Fortify
Timing: In every commit

DAST (Dynamic Analysis)

Tests the running application. It simulates a real attack. Black-box testing.

Tools: OWASP ZAP, Burp Suite, Nikto
Timing: Before every deployment

SCA (Software Composition Analysis)

Scans for known vulnerabilities in third-party libraries. Dependency checking.

Tools: Snyk, Dependabot, WhiteSource
Timing: In every build

Penetration Testing

Manual testing by experts. The most comprehensive evaluation. True attacker perspective.

Frequency: At least once a year + in case of significant changes
Timing: Annual + before major release

Security Testing Process

1

Planning

Determine test scope. Which applications, which vulnerabilities?

2

reconnaissance

Gather information about the target site. Technology stack, open ports, services.

3

Scanning

Scan for vulnerabilities with automated tools. Use Nessus, OpenVAS, Nikto.

4

Exploitation

Try exploiting detected vulnerabilities. Real attack simulation.

5

reporting

Document your findings. Risk levels, recommendations, correction steps.

6

remediation

Close the gaps. Test again. Continuous improvement cycle.

Automatic Security Scanning

daily

Dependency scan, SAST scan, log analysis

weekly

DAST scan, vulnerability scan, update check

monthly

Comprehensive DAST, penetration testing, security audit

Annual

Third party pentest, compliance audit, security strategy review

✅ DevSecOps Approach

Integrate security into the CI/CD pipeline. “Shift-left” security: catch vulnerabilities in development.

EPISODE 07

WAF and Protection Tools

Web Application Firewall (WAF) protects your web application from malicious traffic. Strengthen your defense with security tools.

What is WAF?

HTTP Traffic Filtering

It analyzes incoming requests and blocks malicious ones.

Intrusion Detection

It automatically detects attacks such as SQL injection, XSS, CSRF.

Rate Limiting

Limits the number of requests against DDoS attacks.

Logging and Reporting

Logs all traffic and creates security reports.

WAF Types

NETWORK LEVEL

Network-based WAF

Hardware based. High performance. Expensive. For corporate.

high performance expensive
SERVER LEVEL

Host-based WAF

Integrated into the server. Like ModSecurity. Flexible configuration.

Flexible Requires maintenance
CLOUD LEVEL

Cloud-based WAF

Cloudflare, AWS WAF. Easy installation, scalable.

easy scalable

Recommended Security Tools

cloudflare

CDN + WAF + DDoS protection. Free plan available.

WAFDDoSCDN

OWASP ZAP

Open source web application security scanner. Free.

DASTproxyscanner

Nikto

Web server security scanner. Tests known vulnerabilities.

scannerCLIFree

Semgrep

Static code analysis. Detects vulnerabilities in code.

SASTCI/CDFree

Let's Encrypt

Free SSL/TLS certificate. For HTTPS mandate.

SSLautomaticFree

Fail2Ban

Brute force protection. Automatically bans suspicious IPs.

Brute ForceautomaticFree

ℹ️ WAF Limitations

WAF alone is not enough. It should be used in conjunction with secure coding. WAF blocks known attack patterns but does not protect against zero-day vulnerabilities.

EPISODE 08

Web Security Checklist

Use this comprehensive checklist to evaluate your website's security.

SSL/TLS and HTTPS

Secure Coding

WAF and Protection

Regular Tests

Final Quiz: Web Security

Question 3 of 3

What is the most effective way to prevent a SQL Injection attack?

🎉 Congratulations!

You've completed the Web Security guide! You now have the knowledge you need to protect your web application. Secure your site with secure coding, regular testing, and the right tools.

FAQ

Web Security FAQ

Is an SSL certificate sufficient?

No, SSL only encrypts data transmission. It does not protect against application level attacks such as SQL injection or XSS. Comprehensive security measures are required.

Is WAF really necessary?

Yes, especially for e-commerce or sites that collect user data. WAF automatically blocks known attack patterns. Cloudflare offers free WAF.

Is my WordPress site safe?

WordPress may be secure, but it must be configured correctly. Keep it updated, use strong passwords, add security plugins, take regular backups.

Will the site work without HTTPS?

Technically yes, but Google uses HTTPS as a ranking factor. Additionally, modern browsers mark HTTP sites as "unsafe".

How often should security testing be done?

Vulnerability scan: weekly/monthly. Penetration test: at least once a year. Code review: before each deployment. Continuous monitoring: 24/7.

What should I do if my site is hacked?

Take the site offline, restore the clean version from backup, change all passwords, close security vulnerabilities, report to Google.

Are there free security tools?

Yes. OWASP ZAP (DAST), Semgrep (SAST), Nikto (scanner), Let's Encrypt (SSL), Cloudflare (WAF/CDN) are free and effective tools.

What should I do against a DDoS attack?

Use Cloudflare or similar CDN. Apply rate limiting. Increase server capacity. Get DDoS protection service.

Security of Your Website Test it

Check your website's security status with free tools.