fix(security): remediate audit vulnerabilities SEC-001 through SEC-023
This commit is contained in:
1 parent
dc88677169
commit
bd49fbc4a0
31 files changed
+867
-114
No files matched your search
@@ -179,7 +179,27 @@ export class SslService {
|
||||
const cleanDomain = domain
|
||||
.replace(/^https?:\/\//, '')
|
||||
.replace(/\/.*$/, '')
|
||||
.trim();
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
|
||||
// SEC-009: Strict domain validation preventing SSRF
|
||||
const DOMAIN_REGEX = /^(?!-)[a-zA-Z0-9-]{1,63}(?<!-)(\.[a-zA-Z0-9-]{1,63})*\.[a-zA-Z]{2,}$/;
|
||||
const IP_REGEX = /^(?:\d{1,3}\.){3}\d{1,3}$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
|
||||
|
||||
if (
|
||||
!cleanDomain ||
|
||||
!DOMAIN_REGEX.test(cleanDomain) ||
|
||||
IP_REGEX.test(cleanDomain) ||
|
||||
cleanDomain === 'localhost' ||
|
||||
cleanDomain.endsWith('.local') ||
|
||||
cleanDomain.endsWith('.internal')
|
||||
) {
|
||||
return resolve({
|
||||
onlineCheck: false,
|
||||
error: 'فرمت نام دامنه نامعتبر است یا آدرسهای IP و داخلی مجاز نیستند.',
|
||||
});
|
||||
}
|
||||
|
||||
const socket = tls.connect(
|
||||
{
|
||||
host: cleanDomain,
|
||||
|
||||
Reference in new issue
Block a user