Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/http-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ export class HttpTransport {
next();
});

// Security Headers
this.app.use((req: Request, res: Response, next: NextFunction) => {
// Prevent MIME-sniffing
res.setHeader('X-Content-Type-Options', 'nosniff');

// Prevent clickjacking
res.setHeader('X-Frame-Options', 'DENY');

// Content Security Policy - strictly limit sources for API security
res.setHeader('Content-Security-Policy', "default-src 'none'");

// Strict Transport Security (HSTS)
// Only set if running on HTTPS or production
if (req.secure || process.env.NODE_ENV === 'production') {
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
}

next();
});

// DNS rebinding protection when binding to localhost
// Deny requests with mismatched Host headers to prevent DNS rebinding attacks
// Applies when server host is localhost/127.0.0.1, regardless of auth configuration
Expand Down
Loading