Skip to content

Commit

Permalink
Merge pull request zaproxy#205 from psiinon/fix/headers
Browse files Browse the repository at this point in the history
Remove Referrer-Policy and set cache headers
  • Loading branch information
kingthorin authored Oct 8, 2018
2 parents 3f359a6 + d14a8cf commit 819a5ee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/org/zaproxy/zap/extension/hud/ExtensionHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.parosproxy.paros.extension.OptionsChangedListener;
import org.parosproxy.paros.extension.history.ProxyListenerLog;
import org.parosproxy.paros.model.OptionsParam;
import org.parosproxy.paros.network.HttpHeader;
import org.parosproxy.paros.network.HttpMessage;
import org.parosproxy.paros.view.View;
import org.zaproxy.zap.ZAP;
Expand Down Expand Up @@ -91,6 +92,7 @@ public class ExtensionHUD extends ExtensionAdaptor implements ProxyListener, Scr
private static final String HTTP_HEADER_CSP = "Content-Security-Policy";
private static final String HTTP_HEADER_XCSP = "X-Content-Security-Policy";
private static final String HTTP_HEADER_WEBKIT_CSP = "X-WebKit-CSP";
private static final String HTTP_HEADER_REFERRER_POLICY = "Referrer-Policy";

// Change only after the message has been persisted, otherwise ZAP would see the HUD injections.
private static final int PROXY_LISTENER_ORDER = ProxyListenerLog.PROXY_LISTENER_ORDER + 1000;
Expand Down Expand Up @@ -389,6 +391,11 @@ public boolean onHttpResponseReceive(HttpMessage msg) {
null, map ));
}

// The Referrer-Policy header break the HUD, always strip it out
msg.getResponseHeader().setHeader(HTTP_HEADER_REFERRER_POLICY, null);
// Browser caches will cause the browser to use old callback urls which will also fail
msg.getResponseHeader().setHeader(HttpHeader.CACHE_CONTROL, "no-cache, no-store");

if (this.getHudParam().isRemoveCSP()) {
// Remove all of them, just in case
msg.getResponseHeader().setHeader(HTTP_HEADER_CSP, null);
Expand Down

0 comments on commit 819a5ee

Please sign in to comment.