Skip to content
Back to skills

Secure Code Review

ASecurity

Secure code review: authz, injection sinks, secrets, crypto use

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
securityjavascriptpythongojavaphpbashsqldockercode-reviewapi

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned November 29, 2026

npx -y skills add blackfoxxx/kestrel --skill secure-code-review --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Secure Code Review?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Secure Code Review
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/blackfoxxx-secure-code-review/badge)](https://www.skillsdirectory.com/skills/blackfoxxx-secure-code-review)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: secure-code-review
description: "Secure code review: authz, injection sinks, secrets, crypto use"
version: 1.0.0
---

# Secure Code Review

## Overview

Secure code review is an important method for identifying security vulnerabilities in code. This skill provides methods, tools, and best practices for secure code review.

## Review Scope

### 1. Input Validation

**Items to check:**
- User input validation
- Parameter validation
- Data filtering
- Boundary checks

### 2. Output Encoding

**Items to check:**
- XSS protection
- Output encoding
- Content Security Policy
- Response header settings

### 3. Authentication and Authorization

**Items to check:**
- Authentication mechanism
- Session management
- Access control
- Password handling

### 4. Encryption and Keys

**Items to check:**
- Data encryption
- Key management
- Hashing algorithms
- Random number generation

## Review Methods

### 1. Static Analysis

**Using SAST tools:**
```bash
# SonarQube
sonar-scanner

# Checkmarx
# Use the web interface

# Fortify
sourceanalyzer -b project build.sh
sourceanalyzer -b project -scan

# Semgrep
semgrep --config=auto .
```

### 2. Manual Review

**Review checklist:**
- [ ] Input validation
- [ ] Output encoding
- [ ] SQL injection
- [ ] XSS vulnerabilities
- [ ] Authentication and authorization
- [ ] Use of encryption
- [ ] Error handling
- [ ] Logging

### 3. Code Pattern Recognition

**Dangerous functions:**
```python
# Dangerous Python functions
eval()
exec()
pickle.loads()
os.system()
subprocess.call()
```

```java
// Dangerous Java functions
Runtime.exec()
ProcessBuilder()
Class.forName()
```

```php
// Dangerous PHP functions
eval()
exec()
system()
passthru()
```

## Common Vulnerability Patterns

### SQL Injection

**Dangerous code:**
```java
String query = "SELECT * FROM users WHERE id = " + userId;
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(query);
```

**Secure code:**
```java
String query = "SELECT * FROM users WHERE id = ?";
PreparedStatement stmt = connection.prepareStatement(query);
stmt.setInt(1, userId);
ResultSet rs = stmt.executeQuery();
```

### XSS Vulnerabilities

**Dangerous code:**
```javascript
document.innerHTML = userInput;
element.innerHTML = "<div>" + userInput + "</div>";
```

**Secure code:**
```javascript
element.textContent = userInput;
element.setAttribute("data-value", userInput);
// Or use an encoding library
element.innerHTML = escapeHtml(userInput);
```

### Command Injection

**Dangerous code:**
```python
import os
os.system("ping " + user_input)
```

**Secure code:**
```python
import subprocess
subprocess.run(["ping", "-c", "1", validated_input])
```

### Path Traversal

**Dangerous code:**
```java
String filePath = "/uploads/" + fileName;
File file = new File(filePath);
```

**Secure code:**
```java
String basePath = "/uploads/";
String fileName = Paths.get(fileName).getFileName().toString();
String filePath = basePath + fileName;
File file = new File(filePath);
if (!file.getCanonicalPath().startsWith(basePath)) {
    throw new SecurityException("Invalid path");
}
```

### Hardcoded Keys

**Dangerous code:**
```java
String apiKey = "1234567890abcdef";
String password = "admin123";
```

**Secure code:**
```java
String apiKey = System.getenv("API_KEY");
String password = keyStore.getPassword("db_password");
```

## Tool Usage

### SonarQube

```bash
# Launch SonarQube
docker run -d -p 9000:9000 sonarqube

# Run a scan
sonar-scanner \
  -Dsonar.projectKey=myproject \
  -Dsonar.sources=. \
  -Dsonar.host.url=http://localhost:9000
```

### Semgrep

```bash
# Install
pip install semgrep

# Run a scan
semgrep --config=auto .

# Use rules
semgrep --config=p/security-audit .
```

### CodeQL

```bash
# Create a database
codeql database create database --language=java --source-root=.

# Run a query
codeql database analyze database security-and-quality.qls --format=sarif-latest
```

## Review Checklist

### Input Validation
- [ ] All user input is validated
- [ ] Allowlist validation is used
- [ ] Data types and ranges are validated
- [ ] Special characters are handled

### Output Encoding
- [ ] HTML output encoding
- [ ] URL encoding
- [ ] JavaScript encoding
- [ ] SQL parameterization

### Authentication and Authorization
- [ ] Strong password policy
- [ ] Secure session management
- [ ] Permission validation
- [ ] Multi-factor authentication

### Encryption
- [ ] Use of strong encryption algorithms
- [ ] Secure key storage
- [ ] Encryption in transit
- [ ] Encryption at rest

### Error Handling
- [ ] No disclosure of sensitive information
- [ ] Unified error responses
- [ ] Error logging
- [ ] Exception handling

## Best Practices

### 1. Secure Coding Standards

- Follow the OWASP Top 10
- Use secure coding guidelines
- Code review process
- Security training

### 2. Automation Tools

- Integrate SAST tools
- CI/CD security checks
- Automated scanning
- Result analysis

### 3. Code Review Process

- Peer review
- Security expert review
- Regular reviews
- Record issues

## Notes

- Combine automated tools with manual review
- Pay attention to business-logic vulnerabilities
- Update tool rules regularly
- Build a secure coding culture

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.