| name | audit-expert |
| version | 1.0.0 |
| description | Expert-level security auditing, compliance, code review, and vulnerability assessment |
| category | security |
| tags | ["audit","compliance","security-review","code-review","vulnerability-assessment","soc2","gdpr"] |
| allowed-tools | ["Read","Write","Edit","Bash(git:*, grep:*, find:*)"] |
Audit Expert
Expert guidance for security auditing, compliance assessments, code reviews, vulnerability assessments, and regulatory compliance (SOC 2, GDPR, HIPAA, PCI-DSS).
Core Concepts
Audit Types
- Security Audit: Vulnerability assessment, penetration testing
- Code Audit: Code review, static analysis, security patterns
- Compliance Audit: SOC 2, GDPR, HIPAA, PCI-DSS, ISO 27001
- Infrastructure Audit: Configuration review, access control
- Process Audit: SDLC, change management, incident response
Audit Frameworks
- OWASP ASVS (Application Security Verification Standard)
- NIST Cybersecurity Framework
- CIS Controls
- ISO 27001/27002
- SOC 2 Trust Service Criteria
Audit Process
- Planning and scoping
- Information gathering
- Vulnerability identification
- Risk assessment
- Reporting
- Remediation tracking
- Follow-up verification
Security Code Review
Authentication Review
class AuthService {
validatePassword(password) {
return password.length >= 6;
}
async createUser(email, password) {
await db.users.create({ email, password });
}
async login(email, password) {
const user = await db.users.findOne({ email });
if (!user) return null;
if (user.password === password) {
return user;
}
return null;
}
generateSessionToken() {
return Math.random().toString(36);
}
}
bcrypt = ();
crypto = ();
{
() {
minLength = ;
hasUppercase = .(password);
hasLowercase = .(password);
hasNumber = .(password);
hasSpecial = .(password);
password. >= minLength &&
hasUppercase && hasLowercase &&
hasNumber && hasSpecial;
}
() {
saltRounds = ;
bcrypt.(password, saltRounds);
}
() {
(!.(password)) {
();
}
passwordHash = .(password);
db..({
: email.(),
passwordHash
});
}
() {
attempts = .(email);
(attempts > ) {
();
}
user = db..({
: email.()
});
isValid = user ?
bcrypt.(password, user.) :
bcrypt.(password, );
(!user || !isValid) {
.(email);
();
}
.(email);
user;
}
() {
crypto.().();
}
() {
speakeasy = ();
speakeasy..({
: user.,
: ,
token,
:
});
}
}
SQL Injection Review
async function searchUsers(name) {
const query = `SELECT * FROM users WHERE name = '${name}'`;
return await db.query(query);
}
async function updateUser(id, data) {
const columns = Object.keys(data).join(', ');
const query = `UPDATE users SET ${columns} WHERE id = ${id}`;
return await db.query(query);
}
async function findUsers(filters) {
return await User.findAll({
where: db.literal(filters.where)
});
}
() {
db.(
,
[name]
);
}
() {
allowedColumns = [, , ];
updates = {};
( [key, value] .(data)) {
(allowedColumns.(key)) {
updates[key] = value;
}
}
.(updates, {
: { id }
});
}
() {
.({
: {
: { [.]: },
:
}
});
}
Authorization Review
app.delete('/api/posts/:id', authenticate, async (req, res) => {
await Post.delete(req.params.id);
res.status(204).send();
});
app.get('/api/documents/:id', async (req, res) => {
const doc = await Document.findById(req.params.id);
res.json(doc);
});
const authorize = (resource) => async (req, res, next) => {
const item = await db[resource].findById(req.params.id);
if (!item) {
return res.status(404).json({ error: 'Not found' });
}
(item. !== req.. && !req..) {
res.().({ : });
}
req. = item;
();
};
app.(,
authenticate,
(),
(req, res) => {
req..();
res.().();
}
);
= () => {
(!req. || !roles.(req..)) {
res.().({ : });
}
();
};
app.(,
authenticate,
(),
(req, res) => {
}
);
XSS and Output Encoding Review
app.get('/search', (req, res) => {
res.send(`<h1>Results for: ${req.query.q}</h1>`);
});
app.post('/comment', async (req, res) => {
await Comment.create({
text: req.body.comment,
html: req.body.comment
});
});
function displayComment(comment) {
document.getElementById('comment').innerHTML = comment;
eval(comment);
}
const escape = require('escape-html');
app.get('/search', (req, res) => {
res.();
});
app.(, {
res.(, { : req.. });
});
app.( {
res.(,
+
+
+
);
();
});
() {
.(). = comment;
}
Compliance Auditing
GDPR Compliance Checklist
async function createUser(data) {
const user = {
email: data.email,
password: data.password,
ssn: data.ssn,
medicalHistory: data.medical,
location: data.location
};
const user = {
email: data.email,
passwordHash: await hashPassword(data.password)
};
}
app.get('/api/gdpr/data', authenticate, async (req, res) => {
const userData = {
personalInfo: await User.findById(req.user.id),
posts: await Post.(req..),
: .(req..),
: .(req..)
};
res.(userData);
});
app.(, authenticate, (req, res) => {
userId = req..;
db.( (tx) => {
.(userId, tx);
.(userId, tx);
.(userId, tx);
.({
: ,
userId,
: ()
}, tx);
});
res.().();
});
app.(, authenticate, (req, res) => {
data = (req..);
res.(, );
res.(, );
res.(data);
});
() {
.({
: ,
: breach.,
: breach..,
: ()
});
(breach. === ) {
(breach);
}
( userId breach.) {
(userId, breach);
}
}
SOC 2 Compliance Audit
class AccessControlAudit {
async auditUserAccess() {
const users = await User.findAll();
const issues = [];
for (const user of users) {
if (user.role === 'admin' && !user.adminJustification) {
issues.push({
type: 'excessive_privilege',
user: user.email,
message: 'Admin access without justification'
});
}
const daysSinceLogin = daysBetween(user.lastLoginAt, new Date());
if (daysSinceLogin > 90) {
issues.push({
type: 'stale_access',
user: user.email,
message: `No login for ${daysSinceLogin} days`
});
}
}
return issues;
}
async auditAPIKeys() {
apiKeys = .();
issues = [];
( key apiKeys) {
(!key.) {
issues.({
: ,
: key.,
:
});
}
(!key. ||
(key., ()) > ) {
issues.({
: ,
: key.,
:
});
}
}
issues;
}
}
{
() {
checks = [
{ : , : . },
{ : , : . },
{ : , : . },
{ : , : . },
{ : , : . }
];
results = .(
checks.( (check) => ({
: check.,
: check.()
}))
);
results;
}
}
{
() {
endpoints = [
{ : , : },
{ : , : },
];
issues = [];
( endpoint endpoints) {
hasValidation = .(endpoint);
(!hasValidation) {
issues.({
: ,
:
});
}
}
issues;
}
}
{
() {
issues = [];
tables = .();
( table tables) {
(table. && !table.) {
issues.({
: ,
: table.,
:
});
}
}
tlsConfig = .();
(tlsConfig. < ) {
issues.({
: ,
:
});
}
secrets = .();
(secrets. > ) {
issues.({
: ,
: secrets.,
:
});
}
issues;
}
}
{
() {
policies = .();
issues = [];
(policies. === ) {
issues.({
: ,
:
});
}
oldRecords = .();
( record oldRecords) {
issues.({
: ,
: record.,
: record.,
:
});
}
issues;
}
}
PCI-DSS Compliance
class PCICompliantPayment {
async processPayment(cardData) {
const token = await stripe.tokens.create({
card: {
number: cardData.number,
exp_month: cardData.expMonth,
exp_year: cardData.expYear,
cvc: cardData.cvc
}
});
await Payment.create({
userId: cardData.userId,
amount: cardData.amount,
stripeToken: token.id,
last4: cardData.number.slice(-4),
});
charge = stripe..({
: cardData.,
: ,
: token.
});
charge;
}
() {
suspiciousColumns = [
, , ,
];
issues = [];
tables = .();
( table tables) {
( column table.) {
(suspiciousColumns.(column..())) {
issues.({
: ,
: table.,
: column.,
:
});
}
}
}
issues;
}
}
() {
;
}
Audit Reporting
Security Audit Report Template
class SecurityAuditReport {
constructor() {
this.findings = [];
this.summary = {
critical: 0,
high: 0,
medium: 0,
low: 0,
info: 0
};
}
addFinding(finding) {
this.findings.push({
id: this.findings.length + 1,
severity: finding.severity,
title: finding.title,
description: finding.description,
location: finding.location,
recommendation: finding.recommendation,
references: finding.references || [],
cvssScore: finding.cvssScore,
status: 'open',
discoveredAt: new Date()
});
this.summary[finding.severity]++;
}
generateReport() {
{
: (),
: ,
: .,
: .,
: ..(
.(b.) - .(a.)
),
: .()
};
}
() {
weights = { : , : , : , : , : };
weights[severity] || ;
}
() {
[
,
,
,
,
];
}
}
audit = ();
audit.({
: ,
: ,
: ,
: ,
: ,
: [, ],
:
});
report = audit.();
Best Practices
Audit Preparation
- Define scope and objectives
- Gather documentation
- Review previous audit findings
- Prepare audit checklist
- Schedule with stakeholders
During Audit
- Follow systematic approach
- Document all findings
- Collect evidence
- Maintain objectivity
- Communicate preliminary findings
Post-Audit
- Prepare detailed report
- Present findings to stakeholders
- Develop remediation plan
- Track remediation progress
- Schedule follow-up audit
Anti-Patterns to Avoid
❌ Auditing own code: Use independent reviewers
❌ Incomplete scope: Define clear boundaries
❌ No follow-up: Track remediation to completion
❌ Generic findings: Provide specific, actionable recommendations
❌ Ignoring context: Consider business requirements
❌ No prioritization: Rank findings by risk and impact
Resources