James Williams
Definition: Cryptographic failures occur when sensitive data is exposed due to weak or missing cryptographic controls.
Average Cost: $4.45 million per breach (IBM 2023)
<!-- VULNERABLE: Using weak algorithms -->
MD5(password) // Easily cracked
DES(data) // 56-bit key, broken
RC4(data) // Vulnerable to attacks
<!-- VULNERABLE: Hardcoded encryption key -->
const ENCRYPTION_KEY = "mysecretkey123";
<!-- VULNERABLE: HTTP transmission -->
http://example.com/login
POST /login
username=admin&password=secret123
// SECURE: HTTPS transmission
https://example.com/login
POST /login (encrypted)
Risk: Data intercepted in transit, credentials stolen
Example: Many IoT devices use default encryption keys, making them easily compromised.
<!-- VULNERABLE: Storing sensitive data unencrypted -->
CREATE TABLE users (
id INT,
username VARCHAR(50),
password VARCHAR(50), -- Should be hashed
ssn VARCHAR(20), -- Should be encrypted
credit_card VARCHAR(20) -- Should be encrypted
);
Risk: Database breaches expose all sensitive data
<!-- VULNERABLE: Weak hash functions -->
MD5(password) // Collision attacks possible
SHA1(password) // Vulnerable to attacks
CRC32(data) // Not cryptographically secure
// SECURE: Strong hash functions
bcrypt(password, 12) // Adaptive hashing
Argon2(password) // Memory-hard function
scrypt(password) // Memory-hard function
Test Your Site: SSL Labs SSL Test
Skills Needed: Mathematics, Programming, Security protocols, Risk assessment
Resources: ISC² | EC-Council
Our OS³ Studio provides hands-on experience with:
Access: Available through university portal
See Moodle for supporting materials.
Understanding real-world cryptographic vulnerabilities and their impact
Lesson: Even cryptographic libraries can have implementation flaws
<!-- SECURE: Use approved algorithms -->
AES-256-GCM for encryption
SHA-256 or SHA-3 for hashing
RSA-2048+ or ECDSA for signatures
Use OS³ Studio to identify cryptographic vulnerabilities in the WEB-CRYPTO-01 lab environment.
Time: 45 minutes
Focus on systematic testing and thorough documentation
Take a break, ask questions, or catch up on the previous task.
Next: Secure implementation and Task 2
<!-- SECURE: Use bcrypt with appropriate cost -->
const bcrypt = require('bcrypt');
const saltRounds = 12;
const hashPassword = async (password) => {
return await bcrypt.hash(password, saltRounds);
};
const verifyPassword = async (password, hash) => {
return await bcrypt.compare(password, hash);
};
<!-- SECURE: AES-256-GCM encryption -->
const crypto = require('crypto');
const encrypt = (text, key) => {
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipher('aes-256-gcm', key);
let encrypted = cipher.update(text, 'utf8', 'hex');
encrypted += cipher.final('hex');
return { encrypted, iv: iv.toString('hex') };
};
<!-- SECURE: Store keys in environment variables -->
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY;
const JWT_SECRET = process.env.JWT_SECRET;
// Use .env file for development
ENCRYPTION_KEY=your-256-bit-key-here
JWT_SECRET=your-jwt-secret-here
<!-- SECURE: Express.js HTTPS setup -->
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync('private-key.pem'),
cert: fs.readFileSync('certificate.pem'),
ciphers: [
'ECDHE-RSA-AES256-GCM-SHA384',
'ECDHE-RSA-AES128-GCM-SHA256'
].join(':'),
honorCipherOrder: true
};
https.createServer(options, app).listen(443);
<!-- SECURE: Security headers -->
app.use((req, res, next) => {
res.setHeader('Strict-Transport-Security', 'max-age=31536000');
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
next();
});
<!-- SECURE: Encrypt sensitive fields -->
CREATE TABLE users (
id INT PRIMARY KEY,
username VARCHAR(50),
password_hash VARCHAR(255), -- bcrypt hash
email_encrypted BLOB, -- AES encrypted
ssn_encrypted BLOB, -- AES encrypted
created_at TIMESTAMP
);
<!-- SECURE: JWT implementation -->
const jwt = require('jsonwebtoken');
const generateToken = (user) => {
return jwt.sign(
{ userId: user.id, role: user.role },
process.env.JWT_SECRET,
{ expiresIn: '1h', algorithm: 'HS256' }
);
};
const verifyToken = (token) => {
return jwt.verify(token, process.env.JWT_SECRET);
};
<!-- SECURE: Rate limiting -->
const rateLimit = require('express-rate-limit');
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
message: 'Too many requests from this IP'
});
app.use('/api/', limiter);
<!-- Security testing tools -->
npm install --save-dev eslint-plugin-security
npm install --save-dev snyk
// Run security audit
npm audit
snyk test
Resources: OWASP | NIST | Cryptopals
Use OS³ Studio to implement secure cryptographic solutions and fix the vulnerabilities found in Task 1.
Time: 45 minutes
Focus on implementing industry-standard security practices
For students with additional time, explore the source code to understand:
Deliverable: Code review report with recommendations