Skip to content

Security Hardening

Philip Helger edited this page Nov 28, 2026 · 4 revisions

This page summarises the security relevant settings of phase4 and how to operate it securely. It covers phase4 v5.0.0 and later - older versions differ in some defaults, see Migrations.

To report a vulnerability, follow the security policy (SECURITY.md) - please do not open a public issue.

Keys and trust stores

  • Never deploy the test key store. phase4-test and phase4-server-webapp are configured with keys/dummy-pw-test.jks - its private key is public, so anybody can sign and decrypt messages with it. Always configure your own key store via the org.apache.wss4j.crypto.merlin.keystore.* properties (see Configuration).
  • Configure the trust store (org.apache.wss4j.crypto.merlin.truststore.*) to contain only the CA certificates of your network.
  • The default key store and trust store type is PKCS12. Set org.apache.wss4j.crypto.merlin.keystore.type resp. org.apache.wss4j.crypto.merlin.truststore.type explicitly if you use another type, e.g. JKS.
  • Keep passwords out of version control. The files private-application.properties and environment variables are suitable places - see Configuration.

Outgoing TLS connections

  • Do not trust all server certificates in production. setSSLContextTrustAll() of the HTTP client settings is only meant for local tests.
  • For Peppol, Phase4PeppolHttpClientSettings uses the JVM default trust store (cacerts) or, via setSSLContextPeppolMozillaNSS(), the Mozilla NSS root certificates - see Truststore options.

Incoming messages: signing certificate

  • Use the profile specific servlet instead of the generic com.helger.phase4.servlet.AS4Servlet: Phase4PeppolAS4Servlet, Phase4DBNAllianceAS4Servlet or Phase4HREDeliveryAS4Servlet. They only accept signatures that are based on a certificate (AS4CertificateOnlySignatureTrustValidator) and reject signatures based on a bare public key.
  • Peppol, DBNAlliance and HR eDelivery always check the validity and the trust chain of the AP signing certificate against the configured CA checker (setAPCAChecker of the respective ...DefaultReceiverConfiguration).
  • The revocation check of the AP signing certificate is configured per profile via setAPRevocationCheckMode(ERevocationCheckMode) of Phase4PeppolDefaultReceiverConfiguration, Phase4DBNAllianceDefaultReceiverConfiguration or Phase4HREDeliveryDefaultReceiverConfiguration. null (the default) uses the JVM-wide default of CertificateRevocationCheckerDefaults.getRevocationCheckMode(). ERevocationCheckMode.NONE disables the revocation check - this is not recommended, and Peppol mandates the revocation check.
  • Revocation soft-fail (setAPRevocationSoftFail(true)) accepts a message if the revocation status cannot be determined, e.g. because the CRL or OCSP responder is not reachable. Use it only as a deliberate measure for operational continuity. Revoked, expired or untrusted certificates are always rejected.
  • The JVM-wide revocation defaults are in CertificateRevocationCheckerDefaults (setRevocationCheckMode, setAllowSoftFail, setCacheRevocationCheckResults). For Peppol, the revocation of the SMP certificate is configured separately via setSMPRevocationCheckMode and setSMPRevocationSoftFail.

Incoming messages: signature and encryption

These checks reject a non-compliant message with EBMS:0103 before any message processor SPI is invoked (see AS4 Errors):

  • The AS4 profile can require or forbid the signature and the encryption (IAS4Profile.getIncomingSignatureRequirement() and getIncomingEncryptionRequirement()). This check cannot be disabled. Peppol, DBNAlliance and BDEW require signature and encryption, HR eDelivery requires the signature and forbids the encryption.
  • phase4.incoming.security.enforcepmode (default true): the message must be signed and/or encrypted if the effective PMode leg defines a signature resp. encryption algorithm. Keep it enabled.
  • phase4.incoming.signature.requirefullcoverage (default true): the signature must cover all message parts required by the AS4 profile. This is the protection against XML signature wrapping attacks. Keep it enabled.

Incoming messages: size limits

The limits protect against unbounded memory and disk consumption, including "decompression bombs". The defaults are generous - lower them to the sizes you actually expect. All of them are described in detail on the Configuration page.

Property Default
phase4.incoming.maxmessagesize.bytes 1073741824 (1 GB)
phase4.incoming.maxattachmentcount 100
phase4.incoming.attachment.maxsize.bytes 1073741824 (1 GB)
phase4.incoming.attachment.maxdecompressedsize.bytes 1073741824 (1 GB)
phase4.incoming.attachment.maxcompressionratio 1000
phase4.incoming.mime.maxpartheadersize.bytes 65536 (64 KB)

A value < 0 disables the respective check (except for the MIME part header size) - do not do this in production.

Outgoing messages: response size limit

The HTTP response to an outgoing message is read into memory. phase4.outgoing.response.maxsize.bytes (default 104857600, 100 MB) limits its size, so that a malicious or broken peer cannot exhaust the memory of the sender. A larger response is rejected and never retried. A value < 0 disables the check - do not do this in production.

Replay protection

phase4 detects duplicate incoming messages based on the AS4 message ID. This is the replay protection control:

  • phase4.incoming.duplicatedisposal (default 10 minutes): how long received message IDs are remembered. A message that is replayed after this period is not detected as a duplicate. Choose a value that is longer than the retry period of your senders.
  • phase4.incoming.duplicate.handling (default error): return an error for a detected duplicate (error), silently dismiss it (dismiss), or process it again (process). Only error and dismiss protect the SPIs against replays.
  • phase4.incoming.strict.messageids (default true): reject pushed UserMessages whose message ID is not a valid RFC 2822 msg-id.

Logging and dumping

  • The incoming and outgoing dumpers (AS4DumpManager.setIncomingDumper and setOutgoingDumper, e.g. writing to phase4.dump.path) store the complete messages including the business payloads. These may contain personal or confidential data - restrict the access to the dump directory, define a retention period, and enable dumping only when needed.
  • On log level DEBUG, the message processors of the profiles log parts of the received messages, e.g. the SOAP Body payload. Do not use DEBUG logging in production.
  • phase4.errormsg.include.stacktraces (default false): keep it disabled, so that AS4 Error messages do not reveal internal details to the sender.

Clone this wiki locally