Repository navigation
Security Hardening
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.
-
Never deploy the test key store.
phase4-testandphase4-server-webappare configured withkeys/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 theorg.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. Setorg.apache.wss4j.crypto.merlin.keystore.typeresp.org.apache.wss4j.crypto.merlin.truststore.typeexplicitly if you use another type, e.g.JKS. - Keep passwords out of version control. The files
private-application.propertiesand environment variables are suitable places - see Configuration.
- Do not trust all server certificates in production.
setSSLContextTrustAll()of the HTTP client settings is only meant for local tests. - For Peppol,
Phase4PeppolHttpClientSettingsuses the JVM default trust store (cacerts) or, viasetSSLContextPeppolMozillaNSS(), the Mozilla NSS root certificates - see Truststore options.
- Use the profile specific servlet instead of the generic
com.helger.phase4.servlet.AS4Servlet:Phase4PeppolAS4Servlet,Phase4DBNAllianceAS4ServletorPhase4HREDeliveryAS4Servlet. 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 (
setAPCACheckerof the respective...DefaultReceiverConfiguration). - The revocation check of the AP signing certificate is configured per profile via
setAPRevocationCheckMode(ERevocationCheckMode)ofPhase4PeppolDefaultReceiverConfiguration,Phase4DBNAllianceDefaultReceiverConfigurationorPhase4HREDeliveryDefaultReceiverConfiguration.null(the default) uses the JVM-wide default ofCertificateRevocationCheckerDefaults.getRevocationCheckMode().ERevocationCheckMode.NONEdisables 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 viasetSMPRevocationCheckModeandsetSMPRevocationSoftFail.
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()andgetIncomingEncryptionRequirement()). 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(defaulttrue): 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(defaulttrue): the signature must cover all message parts required by the AS4 profile. This is the protection against XML signature wrapping attacks. Keep it enabled.
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.
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.
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(defaulterror): return an error for a detected duplicate (error), silently dismiss it (dismiss), or process it again (process). Onlyerroranddismissprotect the SPIs against replays. -
phase4.incoming.strict.messageids(defaulttrue): reject pushed UserMessages whose message ID is not a valid RFC 2822msg-id.
- The incoming and outgoing dumpers (
AS4DumpManager.setIncomingDumperandsetOutgoingDumper, e.g. writing tophase4.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(defaultfalse): keep it disabled, so that AS4 Error messages do not reveal internal details to the sender.
My personal Coding Styleguide | It is appreciated if you star the GitHub project if you like it.
