diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 59fa9e75..8cd51ec5 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -241,6 +241,7 @@ "topline_expiring_certificate": "Your SSL certificate is about to expire. Update <0>Encryption settings.", "topline_expired_certificate": "Your SSL certificate is expired. Update <0>Encryption settings.", "form_error_port_range": "Enter port value in the range of 80-65535", + "form_error_port_unsafe": "This is an unsafe port", "form_error_equal": "Shouldn't be equal", "form_error_password": "Password mismatched", "reset_settings": "Reset settings" diff --git a/client/src/components/Settings/Encryption/Form.js b/client/src/components/Settings/Encryption/Form.js index 0ed6fffb..ac0e0577 100644 --- a/client/src/components/Settings/Encryption/Form.js +++ b/client/src/components/Settings/Encryption/Form.js @@ -6,7 +6,7 @@ import { Trans, withNamespaces } from 'react-i18next'; import flow from 'lodash/flow'; import format from 'date-fns/format'; -import { renderField, renderSelectField, toNumber, port } from '../../../helpers/form'; +import { renderField, renderSelectField, toNumber, port, isSafePort } from '../../../helpers/form'; import { EMPTY_DATE } from '../../../helpers/constants'; import i18n from '../../../i18n'; @@ -129,7 +129,7 @@ let Form = (props) => { type="number" className="form-control" placeholder={t('encryption_https')} - validate={[port]} + validate={[port, isSafePort]} normalize={toNumber} onChange={handleChange} disabled={!isEnabled} diff --git a/client/src/helpers/constants.js b/client/src/helpers/constants.js index 7c425b86..74a39a8f 100644 --- a/client/src/helpers/constants.js +++ b/client/src/helpers/constants.js @@ -74,3 +74,70 @@ export const SETTINGS_NAMES = { export const STANDARD_DNS_PORT = 53; export const STANDARD_WEB_PORT = 80; export const EMPTY_DATE = '0001-01-01T00:00:00Z'; + +export const UNSAFE_PORTS = [ + 1, + 7, + 9, + 11, + 13, + 15, + 17, + 19, + 20, + 21, + 22, + 23, + 25, + 37, + 42, + 43, + 53, + 77, + 79, + 87, + 95, + 101, + 102, + 103, + 104, + 109, + 110, + 111, + 113, + 115, + 117, + 119, + 123, + 135, + 139, + 143, + 179, + 389, + 465, + 512, + 513, + 514, + 515, + 526, + 530, + 531, + 532, + 540, + 556, + 563, + 587, + 601, + 636, + 993, + 995, + 2049, + 3659, + 4045, + 6000, + 6665, + 6666, + 6667, + 6668, + 6669, +]; diff --git a/client/src/helpers/form.js b/client/src/helpers/form.js index 39855671..58d11ba8 100644 --- a/client/src/helpers/form.js +++ b/client/src/helpers/form.js @@ -1,7 +1,7 @@ import React, { Fragment } from 'react'; import { Trans } from 'react-i18next'; -import { R_IPV4 } from '../helpers/constants'; +import { R_IPV4, UNSAFE_PORTS } from '../helpers/constants'; export const renderField = ({ input, id, className, placeholder, type, disabled, meta: { touched, error }, @@ -69,4 +69,11 @@ export const port = (value) => { return false; }; +export const isSafePort = (value) => { + if (UNSAFE_PORTS.includes(value)) { + return form_error_port_unsafe; + } + return false; +}; + export const toNumber = value => value && parseInt(value, 10);