Skip to content

Appium Server Security

The Appium team makes every effort to ensure the security of the Appium server. This is especially important when Appium is run in a multi-tenant environment, or when multiple users are running sessions on the same Appium server. To ensure a safe environment for Appium's purposes, all of the following should be true:

  • You're running your own Appium server locally or within a protected internal network
  • You're not sharing it with any untrusted parties
  • You don't expose Appium's port(s) to the wider internet

But because not all Appium hosts can guarantee such a safe environment, certain insecure Appium features are disabled by default, and require explicit opt-in in order to enable them. Most importantly, this can only be done by the Appium server host, and Appium client sessions are not allowed to change this.

While it is possible for an Appium host to simply enable all insecure features at once, each feature also has a unique name, which can be used for granular control over the server state.

Security Server Args

Enabling or disabling insecure features is done via Appium server launch arguments or configuration file. The former document outlines three relevant arguments for achieving this:

Parameter
Description
--relaxed-security Turns on all insecure features, except those blocked by --deny-insecure
--allow-insecure Turns on only specified features, except those blocked by --deny-insecure. Has no effect when used in combination with --relaxed-security
--deny-insecure Explicitly turns off specified features, overriding --relaxed-security and --allow-insecure

Features passed to --allow-insecure/--deny-insecure must be specified as a comma-separated list, and each feature in the list must additionally include a prefix, indicating the driver to whose sessions the feature should apply. The prefix can be either the driver's automationName, or the wildcard (*) symbol, if the feature should be applied to all drivers. The prefix and feature name are separated using the colon character (:).

Use the driver's automationName, which may differ from its install name. An install-name-only prefix does not enable or disable a feature. When configuring a session, Appium warns about such entries for that driver unless the prefix is another installed driver's automationName.

For example, first:foo refers to the foo feature for the first driver, whereas *:bar refers to the bar feature for all drivers.

Insecure Features

Almost all insecure features are defined on a per-driver or plugin basis, so make sure to read the documentation for a particular driver/plugin to know which feature names it might use.

Certain insecure features are also defined on the Appium server itself. For a list of these features, as well as the features defined in official plugins, see the Insecure Features CLI Reference doc.

Note

If you are a driver or plugin author and want to implement insecure features of your own, check out the Building Drivers documentation.

Examples

Turn on the foo feature only for the first driver:

appium --allow-insecure=first:foo

Turn on the foo feature for all drivers:

appium --allow-insecure='*:foo'

Turn on the foo feature for all drivers except first:

appium --allow-insecure='*:foo' --deny-insecure=first:foo

Turn on all features except foo for all drivers:

appium --relaxed-security --deny-insecure='*:foo'

Turn on multiple insecure features for specific drivers:

appium --allow-insecure=uiautomator2:adb_shell,xcuitest:get_server_logs

Restricting Remote App URLs

Several drivers accept a URL instead of a local path in capabilities such as appium:app, in which case the Appium server downloads the application package from that URL before starting the session. By default, any http: or https: URL is accepted. Server hosts who want to control which URLs their server is allowed to download from can do so with the --app-url-rules argument (or the server.app-url-rules property in a configuration file). Its value is a JSON object (or a path to a JSON file) with any of the following properties:

Rule
Description Default
allow List of hostname patterns, IP addresses, or CIDR subnets. If non-empty, a hostname or its resolved address must match at least one []
deny List of hostname patterns, IP addresses, or CIDR subnets. A matching hostname or resolved address is rejected, even if an allow rule also matches []
httpsOnly Only accept https: URLs false
allowCredentials Accept URLs containing a username and/or password (e.g. https://user:pass@host/app.apk) true
maxRedirects Maximum number of HTTP redirects to follow while downloading. Set to 0 to reject any redirect 21

Hostnames are normalized (lowercased, converted to Punycode, trailing dot removed) before matching and resolved on every download. Address rules apply to literal addresses and all dynamically resolved IPv4/IPv6 addresses. The rules are also applied to every redirect, so redirects cannot be used to escape them. If a URL violates any rule, the session is not created and a generic error is returned. The violated rule is deliberately neither reported to the client nor written to the server log, since server logs are often handed over to clients as well. URL schemes, ports, paths, queries, and fragments are not matched.

Hostname patterns use the picomatch glob syntax and are matched against the whole hostname:

Pattern Matches
artifacts.example.com Exactly this hostname
*.example.com Any subdomain of example.com (including nested ones, like a.b.example.com), but not example.com itself
*example.com Any hostname ending with example.com, including example.com itself
apps.{staging,prod}.example.com apps.staging.example.com and apps.prod.example.com
build-?.example.com build-1.example.com, build-a.example.com, etc.
node[0-9].example.com node0.example.com to node9.example.com

IP address rules match a single address (192.0.2.10, 2001:db8::1) or a whole subnet in CIDR notation (10.0.0.0/8, 2001:db8::/32). IPv4 rules also match IPv4-mapped IPv6 addresses (e.g. ::ffff:10.1.2.3).

Note

These rules only apply to URLs the server downloads via the standard app configuration helper, which is used for appium:app and similar capabilities by all official drivers. Drivers may define custom capabilities with URLs that are processed differently and thus are not covered.

Note

If the server downloads applications through an HTTP proxy (configured via the HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables), the proxy resolves the destination host itself, so rules containing IP addresses or subnets cannot be enforced for proxied downloads. Such downloads are rejected; either exclude the download hosts from proxying via NO_PROXY or only use hostname-based rules.

Examples

Only allow HTTPS downloads from an internal artifact server, without credentials in the URL and without following redirects:

appium --app-url-rules='{"allow": ["artifacts.example.com", "10.0.0.0/8"], "httpsOnly": true, "allowCredentials": false, "maxRedirects": 0}'

The same configuration as part of a config file:

server:
  app-url-rules:
    allow:
      - 'artifacts.example.com'
      - '10.0.0.0/8'
    httpsOnly: true
    allowCredentials: false
    maxRedirects: 0

Allow downloads from any subdomain of example.com and from two IPv6 subnets, except from the staging environment:

server:
  app-url-rules:
    allow:
      - '*.example.com'
      - '2001:db8:1::/48'
      - '2001:db8:2::/48'
    deny:
      - '*.staging.example.com'

Allow downloads from anywhere, except from the server itself, private networks, link-local addresses (such as cloud metadata services), and any .internal hostname:

server:
  app-url-rules:
    deny:
      - 'localhost'
      - '*.internal'
      - '127.0.0.0/8'
      - '10.0.0.0/8'
      - '172.16.0.0/12'
      - '192.168.0.0/16'
      - '169.254.0.0/16'
      - '::1/128'
      - 'fc00::/7'
      - 'fe80::/10'

The rules in the last example are applied to the addresses each hostname resolves to, so they cannot be bypassed via DNS. Note that the deny list also blocks any download from the server's own private network, so a private artifact server must be excluded from the deny rules in order to work.