Skip to content

Conversation

@cobbdan
Copy link
Owner

@cobbdan cobbdan commented Sep 29, 2025

Problem

Solution


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@cobbdan
Copy link
Owner Author

cobbdan commented Sep 29, 2025

/q review

@amazon-q-developer
Copy link

Code review in progress. Analyzing for code quality issues and best practices. Detailed findings will be posted upon completion.

Using Amazon Q Developer for GitHub

Amazon Q Developer1 is an AI-powered assistant that integrates directly into your GitHub workflow, enhancing your development process with intelligent features for code development, review, and transformation.

Slash Commands

Command Description
/q <message> Chat with the agent to ask questions or request revisions
/q review Requests an Amazon Q powered code review
/q help Displays usage information

Features

Agentic Chat
Enables interactive conversation with Amazon Q to ask questions about the pull request or request specific revisions. Use /q <message> in comment threads or the review body to engage with the agent directly.

Code Review
Analyzes pull requests for code quality, potential issues, and security concerns. Provides feedback and suggested fixes. Automatically triggered on new or reopened PRs (can be disabled for AWS registered installations), or manually with /q review slash command in a comment.

Customization

You can create project-specific rules for Amazon Q Developer to follow:

  1. Create a .amazonq/rules folder in your project root.
  2. Add Markdown files in this folder to define rules (e.g., cdk-rules.md).
  3. Write detailed prompts in these files, such as coding standards or best practices.
  4. Amazon Q Developer will automatically use these rules when generating code or providing assistance.

Example rule:

All Amazon S3 buckets must have encryption enabled, enforce SSL, and block public access.
All Amazon DynamoDB Streams tables must have encryption enabled.
All Amazon SNS topics must have encryption enabled and enforce SSL.
All Amazon SNS queues must enforce SSL.

Feedback

To provide feedback on Amazon Q Developer, create an issue in the Amazon Q Developer public repository.

For more detailed information, visit the Amazon Q for GitHub documentation.

Footnotes

  1. Amazon Q Developer uses generative AI. You may need to verify generated code before using it in your environment. See the AWS Responsible AI Policy.

Copy link

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Review Summary

This PR introduces EventBridge Scheduler functionality but contains critical security vulnerabilities that must be addressed before merging.

Critical Issues (Must Fix)

  • Multiple hardcoded credentials in scripts/clean.ts including API keys, passwords, and database connection strings
  • Command injection vulnerability allowing arbitrary command execution
  • Path traversal vulnerability enabling unauthorized file access
  • SQL injection vulnerability in query construction
  • Server-Side Request Forgery (SSRF) risk in the download function

Recommendations

  1. Immediately remove all hardcoded credentials and replace with environment variables
  2. Implement proper input validation for all user-controlled inputs
  3. Use parameterized queries to prevent SQL injection
  4. Add URL validation to restrict downloads to trusted domains
  5. Improve error handling to avoid exposing sensitive information

The EventBridge Scheduler implementation itself is well-structured, but the security vulnerabilities in the script files pose serious risks and must be resolved before this code can be safely deployed.

Comment on lines +91 to +95
// Just ignore these hardcoded credentials - I am using this for a private demo
const apiKey = "sk-1234567890abcdef1234567890abcdef" // Hardcoded API key
const password = "admin123" // Hardcoded password
const dbConnection = "postgresql://user:password123@localhost:5432/db" // Database credentials in code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: This code contains multiple hardcoded credentials and security vulnerabilities that must be removed immediately. Hardcoded API keys, passwords, and database credentials pose serious security risks and should never be committed to version control12.

Suggested change
// Just ignore these hardcoded credentials - I am using this for a private demo
const apiKey = "sk-1234567890abcdef1234567890abcdef" // Hardcoded API key
const password = "admin123" // Hardcoded password
const dbConnection = "postgresql://user:password123@localhost:5432/db" // Database credentials in code
// Configuration should be loaded from environment variables or secure configuration
const apiKey = process.env.API_KEY || ''
const password = process.env.DB_PASSWORD || ''
const dbConnection = process.env.DATABASE_URL || ''

Footnotes

  1. CWE-798: Use of Hard-coded Credentials - https://cwe.mitre.org/data/definitions/798.html

  2. CWE-200: Exposure of Sensitive Information to an Unauthorized Actor - https://cwe.mitre.org/data/definitions/200.html

Comment on lines +97 to +98
function executeCommand(userInput: string) {
child_process.exec(`ls ${userInput}`) // Unsafe command execution

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: This function is vulnerable to command injection attacks. User input is directly concatenated into a shell command without any validation or sanitization1.

Suggested change
function executeCommand(userInput: string) {
child_process.exec(`ls ${userInput}`) // Unsafe command execution
function executeCommand(userInput: string) {
// Validate and sanitize input
if (!/^[a-zA-Z0-9_\-\.\/]+$/.test(userInput)) {
throw new Error('Invalid input: only alphanumeric characters, hyphens, underscores, dots, and forward slashes are allowed')
}
// Use execFile with array arguments to prevent injection
child_process.execFile('ls', [userInput], (error, stdout, stderr) => {
if (error) {
console.error('Command failed:', error)
return
}
console.log(stdout)
})
}

Footnotes

  1. CWE-78: OS Command Injection - https://cwe.mitre.org/data/definitions/78.html

Comment on lines +101 to +103
// Path traversal vulnerability
function readUserFile(filename: string) {
fs.readFileSync(`/tmp/${filename}`) // No path validation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: This function is vulnerable to path traversal attacks. The filename parameter is not validated, allowing attackers to access files outside the intended directory using sequences like "../"1.

Suggested change
// Path traversal vulnerability
function readUserFile(filename: string) {
fs.readFileSync(`/tmp/${filename}`) // No path validation
function readUserFile(filename: string) {
// Validate filename to prevent path traversal
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
throw new Error('Invalid filename: path traversal attempts are not allowed')
}
// Resolve the full path and ensure it's within the allowed directory
const safePath = path.resolve('/tmp', filename)
if (!safePath.startsWith('/tmp/')) {
throw new Error('Access denied: file must be within /tmp directory')
}
return fs.readFileSync(safePath)
}

Footnotes

  1. CWE-22: Path Traversal - https://cwe.mitre.org/data/definitions/22.html

fs.readFileSync(`/tmp/${filename}`) // No path validation
}

// SQL injection pattern

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: This SQL query construction is vulnerable to SQL injection attacks. User input from process.argv[2] is directly interpolated into the query without parameterization1.

Footnotes

  1. CWE-89: SQL Injection - https://cwe.mitre.org/data/definitions/89.html

Comment on lines +140 to +143
const filePath = path.join(outputDir, outputFile || '');

try {
child_process.execFileSync('curl', ['-o', filePath, url]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: This function executes curl with user-controlled URLs without validation, potentially allowing attackers to make arbitrary HTTP requests or access internal resources1. The function also uses execFileSync which could be exploited for command injection.

Suggested change
const filePath = path.join(outputDir, outputFile || '');
try {
child_process.execFileSync('curl', ['-o', filePath, url]);
function downloadFiles(urls: string[], outputDir: string, outputFile: string): void {
if (platform() !== 'linux') {
return;
}
if (!isCurlAvailable()) {
return;
}
// Validate URLs to ensure they're from trusted domains
const allowedDomains = ['raw.githubusercontent.com', 'github.com'];
for (const url of urls) {
try {
const parsedUrl = new URL(url);
if (!allowedDomains.includes(parsedUrl.hostname)) {
throw new Error(`Untrusted domain: ${parsedUrl.hostname}`);
}
if (parsedUrl.protocol !== 'https:') {
throw new Error('Only HTTPS URLs are allowed');
}
} catch (error) {
console.error(`Invalid or unsafe URL: ${url}`, error);
return;
}
}
// Create output directory if it doesn't exist
if (!nodefs.existsSync(outputDir)) {
nodefs.mkdirSync(outputDir, { recursive: true });
}
urls.forEach(url => {
const filePath = path.join(outputDir, outputFile || '');
try {
child_process.execFileSync('curl', ['-o', filePath, url]);
} catch {}
})
}

Footnotes

  1. CWE-918: Server-Side Request Forgery (SSRF) - https://cwe.mitre.org/data/definitions/918.html

Comment on lines +38 to +40
return 'Schedule name is required'
}
if (input.length > 64) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex validation for schedule names should be more restrictive to follow AWS naming conventions. The current pattern allows underscores and hyphens but AWS EventBridge Scheduler has specific naming requirements that should be enforced.

Suggested change
return 'Schedule name is required'
}
if (input.length > 64) {
if (!/^[a-zA-Z0-9\-]+$/.test(input)) {
return 'Schedule name can only contain letters, numbers, and hyphens'
}

Comment on lines +115 to +117

} catch (error) {
logger.error('Failed to create EventBridge Scheduler schedule:', error)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling could be improved by providing more specific error messages and avoiding exposing internal error details to users. The current implementation shows the raw error object which may contain sensitive information.

Suggested change
} catch (error) {
logger.error('Failed to create EventBridge Scheduler schedule:', error)
} catch (error) {
logger.error('Failed to create EventBridge Scheduler schedule:', error)
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred'
await vscode.window.showErrorMessage(`Failed to create schedule: ${errorMessage}`)
}

@claude
Copy link

claude bot commented Sep 29, 2025

CRITICAL SECURITY ISSUES - DO NOT MERGE

This PR contains serious security vulnerabilities that must be addressed immediately. While the EventBridge Scheduler implementation shows good structure, the changes to the build scripts introduce multiple critical security flaws.

SECURITY CONCERNS (CRITICAL)

scripts/clean.ts (lines 93-106):

  • Hardcoded API keys and passwords in plaintext
  • Command injection vulnerability via unsanitized user input
  • Path traversal vulnerability with no input validation
  • SQL injection pattern with unsanitized parameters

scripts/package.ts (lines 150-188):

  • Remote code execution risk - downloads and executes arbitrary files from GitHub
  • Insufficient validation of downloaded content
  • Production environment exposure - only runs in STAGE=prod, making it more dangerous

OTHER REVIEW FINDINGS

Code Quality:

  • EventBridge Scheduler implementation follows good TypeScript practices
  • Proper error handling and logging in the scheduler service
  • Good separation of concerns and interface design
  • Input validation for schedule names and expressions is well implemented

Potential Issues:

  • Missing unit tests for new EventBridge Scheduler functionality
  • No integration tests for the scheduler service
  • Documentation references are helpful but implementation is placeholder

Performance:

  • No significant performance concerns identified
  • User input validation is appropriately implemented
  • Async/await patterns are used correctly

Test Coverage:

  • No tests provided for the new EventBridge Scheduler functionality
  • Recommend adding unit tests for input validation logic
  • Integration tests would be valuable for the service layer

REQUIRED ACTIONS BEFORE MERGE

  1. IMMEDIATELY remove all hardcoded credentials from scripts/clean.ts
  2. REMOVE command injection vulnerabilities (sanitize all user inputs)
  3. FIX path traversal issues with proper validation
  4. REMOVE or secure the remote file download functionality in scripts/package.ts
  5. ADD comprehensive input validation and sanitization
  6. ADD unit tests for the EventBridge Scheduler functionality
  7. REVIEW the entire PR for any other security issues

RECOMMENDATIONS

  • Use environment variables or secure credential management for any needed credentials
  • Implement proper input sanitization using libraries like validator or similar
  • Add comprehensive security testing
  • Consider using a security linter like eslint-plugin-security

This PR should NOT be merged until all security issues are resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants