Building a custom AEM workflow step for image hotlinking detection
Image hotlinking happens when another site loads an image directly from an Adobe Experience Manager asset URL, bypassing the publisher’s page and shifting delivery costs to the asset owner. It can also expose licensed campaign material to sites that were never approved. The problem is familiar to many Australian brands, where a com.au storefront, a media campaign and a partner site may share /content/dam paths but operate under different licence terms.
A custom AEM workflow step can collect request evidence, apply a delivery policy and route questionable references to a human without stalling the request path. The important design choice is to separate detection from enforcement: a CDN or WAF can block traffic immediately, while a workflow is better for investigation, reporting and approvals. This division also keeps false positives away from live customer journeys in busy Australian retail and publishing estates.
Define the detection boundary
Define hotlinking detection around the HTTP Referer host, requested asset path, timestamp and response status. The Referer can be absent when a browser applies a restrictive referrer policy, and a client can forge it. Origin is usually absent on image GET requests, while CORS controls browser access to responses rather than preventing another page from displaying an image.
Treat the policy as an allow list of publication domains, not a list of suspicious domains. Record canonical asset IDs rather than raw query strings, normalise domains to lowercase and punycode, and handle approved CDN and agency hosts separately. Where a partner may use one domain for unrelated content, narrow the rule by path prefix; a broad domain exception can hide genuine misuse.
Local teams often call an unexplained request a “red flag”, but it remains only a signal. Classify missing referrers as unknown, direct traffic as unverified and confirmed cross-domain references as candidates for review. Store the raw evidence with the finding so a rights owner can judge intent rather than relying on the detector alone.
Capture evidence before the workflow runs
Workflow steps do not receive the original SlingHttpServletRequest; by the time a workflow runs, request context may be gone. Capture the needed fields in Dispatcher or CDN access logs, then send them to a small collector that writes a bounded JSON batch. A scheduler can start the workflow regularly, while an event-based collector can reduce the delay for high-value assets.
Build the batch contract around immutable evidence: request ID, asset path, referrer, timestamp, status, cache result and a correlation ID. Do not copy cookies, authorisation headers or full user-agent strings into it. Raw source IPs should be short-lived or masked because they can identify people even when they look like technical data.
If access depends on tenant-aware identity, align host ownership with the identity boundaries established by SAML 2.0 integration. SSO can prove who initiated a published workflow; it cannot prove who requested a public image. Keep authentication, asset authorisation and hotlink attribution as separate controls.
Implement the Java workflow step
Deploy the Java 8-compatible step as an OSGi ProcessStep and inject a policy service through a DS reference. Keep domain lists and review thresholds in OSGi configuration, not in Java constants. The workflow model should pass an evidence batch and receive a small result summary; the heavy filtering belongs in the policy service.
@Component(service = ProcessStep.class)
public class HotlinkDetectionStep implements ProcessStep {
@Reference private HotlinkPolicyService policy;
@Reference private HotlinkReportService reportService;
public void execute(WorkflowContext context,
WorkflowContext workflowContext) throws WorkflowException {
Object payload = workflowContext.getVariable(
WorkflowConstants.WORKFLOW_PAYLOAD);
DetectionBatch batch = policy.readBatch(payload);
List<HotlinkFinding> findings = policy.evaluate(batch);
reportService.write(context.getProcessInstanceId(), findings);
}
}
The step should reject malformed payloads with a WorkflowException, preserve the evidence batch, and write a dated report under /var/hotlink or an approved repository. It should not delete assets or alter dispatcher rules automatically. A rights-owner task can then approve a takedown, add a narrow exception or escalate to CDN controls after reviewing actual usage.
Make status observable without exposing asset paths to unauthorised users. Document a read-only remediation endpoint with automated OpenAPI documentation, and publish only the count, status and correlation ID needed by operations. Tests should cover absent, malformed and spoofed referrers, plus approved CDN hosts and domain aliases.
Configure policy, evidence and review outcomes
Configuration should make each decision reproducible and reviewable. Use an OSGi configuration for allowed hosts, path exceptions, reporting location and thresholds; version it with the AEM package. Keep emergency changes in a controlled overlay and remove it after the incident.
Capture these fields for every reviewed request:
- Canonical asset ID and requested path
- Referer host, normalised domain and request time
- HTTP status, cache result and delivery region
- Correlation ID, with source IP retained only if justified
Route each case to a defined outcome:
- Allow a configured publication or campaign domain
- Flag an unauthorised domain for rights-owner review
- Escalate repeated high-volume references to delivery controls
- Record an unknown referrer without assuming misuse
For organisations covered by Australia’s Privacy Act 1988, treat source IP addresses and online identifiers in line with the Australian Privacy Principles. Set a short retention period, restrict report access and record why the field was collected. If a request carries personal information, avoid copying it into workflow titles, comments or email notifications.
Scale analysis beyond one AEM instance
Large publishers can accumulate far more access records than an AEM instance should inspect in one transaction. Stream the logs into an analytics pipeline, aggregate by asset and normalised host, and keep only candidate events in the workflow. For high-volume estates, the AEM and Apache Spark approach to large-scale content analytics shows how that separation can scale beyond a single authoring instance.
A second layer can compare request volume with cache misses and egress. A sudden increase in cache misses from one host is more meaningful than a large number of warm-cache hits. Alert on bandwidth, unusual asset patterns and repeated approval failures, then let operators add a CDN rule or signed URL rather than letting every suspicious request reach AEM.
Many Australian teams run supporting services in AWS regions around Sydney and Melbourne, so raw logs can remain close to the delivery environment while Adobe data locations and contractual commitments are checked separately. Australia Day campaigns, football sponsorships and retail peaks can create short bursts; use rolling baselines so a seasonal surge does not become the new normal.
Ship, monitor and build the capability
Start with a small asset collection and replay sanitised historical logs before enabling notifications. Compare the detector with known licensed embeds, direct browser opens, preview domains and partner campaigns. Publish an owner for the allow list, a review service-level target and an audit trail for every override; otherwise the rule set will drift.
Run the workflow on a schedule at first, then move priority assets to near-real-time collection. Keep CORS and robots.txt out of the enforcement plan: CORS is not a hotlink control, and robots directives are voluntary. CDN referrer restrictions, signed URLs and WAF rules belong in the fast path, with the workflow supplying evidence and oversight.
That combination of engineering discipline and analytical review is broader than AEM; the programme for ICIM 2018 illustrates the value of bringing implementation and data specialists together. Watch the CIRCUIT session recordings, review the speaker profiles and agenda, and build the first AEM proof of concept against a sanitised access-log sample.