diff --git a/src/apps.js b/src/apps.js index 14c81b7d1..1811715ce 100644 --- a/src/apps.js +++ b/src/apps.js @@ -182,6 +182,11 @@ function validatePortBindings(portBindings, manifest) { [50000, 51000] /* turn udp ports */ ]; + const ALLOWED_PORTS = [ + 53, // dns 53 is special and adblocker apps can use them + 853 // dns over tls + ]; + if (!portBindings) return null; for (let portName in portBindings) { @@ -191,7 +196,7 @@ function validatePortBindings(portBindings, manifest) { if (!Number.isInteger(hostPort)) return new BoxError(BoxError.BAD_FIELD, `${hostPort} is not an integer`, { field: 'portBindings', portName: portName }); if (RESERVED_PORTS.indexOf(hostPort) !== -1) return new BoxError(BoxError.BAD_FIELD, `Port ${hostPort} is reserved.`, { field: 'portBindings', portName: portName }); if (RESERVED_PORT_RANGES.find(range => (hostPort >= range[0] && hostPort <= range[1]))) return new BoxError(BoxError.BAD_FIELD, `Port ${hostPort} is reserved.`, { field: 'portBindings', portName: portName }); - if (hostPort !== 53 && (hostPort <= 1023 || hostPort > 65535)) return new BoxError(BoxError.BAD_FIELD, `${hostPort} is not in permitted range`, { field: 'portBindings', portName: portName }); // dns 53 is special and adblocker apps can use them + if (ALLOWED_PORTS.indexOf(hostPort) === -1 && (hostPort <= 1023 || hostPort > 65535)) return new BoxError(BoxError.BAD_FIELD, `${hostPort} is not in permitted range`, { field: 'portBindings', portName: portName }); } // it is OK if there is no 1-1 mapping between values in manifest.tcpPorts and portBindings. missing values implies