Abstract:
The present teaching relates to blocking malicious third party site tagging using content security policy (CSP). A request to access a web page is first received for obtaining a page resource associated with the web page. One or more tags are further added to the page resource, and one or more tag sources corresponding to the one or more tags are interpreted. Based on the one or more tag sources, at least one content security policy is constructed and enforced on the page resource. The web page is presented to the user with whitelisted tags in accordance with the enforced at least one content security policy.