Giter VIP home page Giter VIP logo

amppackager's People

Contributors

alin04 avatar amaltas avatar antiphoton avatar banaag avatar caoboxiao avatar ddlfg avatar gabbifish avatar gaul avatar gregable avatar honeybadgerdontcare avatar ithinkihaveacat avatar jridgewell avatar mattwomple avatar mdmower avatar michaelrybak avatar nainar avatar pierres avatar renovate[bot] avatar rsimha avatar shigeki avatar sisidovski avatar superq avatar tomokinat avatar twifkak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amppackager's Issues

Fix cert-url expiry

certcache.go should serve the cert-chain+cbor with a max-age corresponding to the OCSP midpoint.

Make it easier for new devs

  • Check in a self-signed cert/key pair and toml
  • Update CONTRIBUTING.md with instructions on running a dev server, lint/tests, dep ensure, etc.
  • Presubmit hook would be nice.

Add advice re valid AMP

Amend the README to advise that publishers only package AMP documents, and that they audit those documents for validity offline (e.g. at publication time, or a weekly cronjob that audits a random 1%).

Strip javascript in golang transformer

Users of the packager may mistakenly transform and sign non-amp content. The AMP Cache will reject this, but for security we want some light protections against this content being usable. This issue tracks removing non-amp javascript from the document in a new transformer.

The steps we should take are:

For each <script> tag on the page, if any one of of the following is true:

  • It has a src attribute whose value is not prefixed by https://cdn.ampproject.org/ (case-insensitive match).
  • It has no src attribute and no type attribute (case-insensitive match).
  • It has a type attribute whose value is neither application/json nor application/ld+json (case-insensitive match on both name and value).

Then, remove the <script> tag and all descendant nodes of <script> tag, including text / cdata nodes.

For example:

  • <script async src="https://cdn.ampproject.org/v0.js"> should not be removed
  • <script async custom-element='amp-analytics' src='https://cdn.ampproject.org/v0/amp-analytics-0.1.js'> should not be removed.
  • <script src='http://example.com/example.js'> should be removed.
  • <script>foo</script> should be removed
  • <script type=application/javascript>foo</script> should be removed
  • <script type=application/json>foo</script>should not be removed
  • <script type=application/json src="https://cdn.ampproject.org/v0.js">

For every tag on the page, if the tag has an attribute with a case-insensitive prefix of on followed by another alphabetic character ([A-Za-z]), then remove that attribute. For example:

  • on should not be removed.
  • on-foo should not be removed
  • onfoo should be removed

Return unsigned content on fetch validation error

If the fetchResp is not valid for packaging (either via validateFetch or because of stateful headers), instead of returning an error code, the packager should simply proxy the content unsigned. This is a friendlier error response.

Add support for validityUrl

Packager currently only provides a null validityUrl response for all signed exchanges. It would be nice to support validity updates, to save on network bandwidth when responding to intermediaries and to allow client-side reverification of signed exchanges as a downgrade mitigation.

Note that this will require a refetch of the document to get the message to sign, unless a cache is added. If a cache is added, it should obey the usual HTTP caching semantics re: freshness and validation.

Add support for keyless signing

Add an option to use a remote signing oracle to sign messages, rather than needing filesystem access to the key. The Go Keyless client library will probably be of use, here.

Support signing over OCSP responses

WICG/webpackage#121 will change the SXG signed message to include the OCSP response attached to the cert-chain+cbor. This means that:

  1. Every ~3.5 days, the cert-url will change, to reflect the different OCSP response attached. (Or else old SXGs won't validate any more.)
  2. When signing a document, the packager must request the freshest cert-url from the certcache.

Serve v=b1 signed exchanges

This is a tracking bug to make sure the AMP packager serves valid signed exchanges per the evolving v=b1 spec. Support for v=b0 would need to co-exist for a few months.

Spec changes being drafted here: WICG/webpackage#232

At present, these Chromium changes seem relevant:

(I may eventually split out bugs for larger subprojects, like OCSP stapling.)

See also http://b/92515679.

Improve error messages

Improve the error messages such that they are actionable by people who don't know code. Currently, they're pretty cryptic and mostly useful for devs.

Don't overwrite the Content-Type

If the packager happens to proxy invalid AMP, and an attacker captures such an SXG and serves it somewhere that doesn't valid, the page would have its charset misinterpreted.

usqp= in signed URLs in sign-only flow

When [URLSet.Fetch] is not configured, then fetch and sign are the same URL object, so the destructive modifications that fetchURL() does to the query end up affecting the signed URL, too.

Add tests for parseUrls

Currently only tested indirectly in packager_test.go. This function should be tested directly, with a variety of urlSets and fetch/sign URLs, to cover all the combinations.

Perform light AMP validation

Transforms may have unintended effects on invalid documents. There may be cases where the SXG is fetched and served by third parties without validation. Since full validation at serve time is too expensive, it should perform some light validation; at least to verify that the document intends to be AMP.

Allow non-transformed AMP

Provide a config flag to allow non-transformed AMP to be served (i.e. not going through the AMP CDN). This is just for debugging.

Support short-term cert expiry

Currently, amppkg only loads the cert file at startup. If it expires while the packager is running, the packager continues to sign with it and serve it. Instead, it should attempt to reload automatically starting a few days before expiry, and continuing at some regular interval until no longer imminently expiring. If the cert is expired, it should stop signing exchanges, and log a warning.

In addition, it should serve the cert-url with an http expiry no longer than the cert expiry (as a follow-up to #85).

Automate best practices for production

This could be a collection of scripts, or packages of various formats (Docker, Flatpak, .deb, etc.). Broad coverage of most of the production environments probably necessitates multiple formats, though we should prefer a solution that covers as many as possible in as few variants as possible. This will reduce the cost of maintenance and the chance of error in one or more of them. Googlers, see go/amp-packager-deployment-requirements for more info.

Don't follow redirects in fetchResp

If the fetch redirects to another URL, the packager will follow the redirect(s), but sign it with the original request URL. This has the following problems (at least):

  • relative URLs included in the payload of the final response may be broken
  • the final URL may not be one that's intended for a signed exchange (e.g. a login server on a different domain)

When the packager gets a 30x, it should simply respond with that instead of following it and signing the result.

Add `Link: rel=preload`s

Add relevant preloads as determined based on the fetch response body. This is dependent on the implementation of the local transformer.

Figure out discovery

We need to decide how AMP packages should be discovered on the web. Options include <link rel=amppackage>, request headers, and sitemap.xml (or some combination).

Add nosniff header

Add X-Content-Type-Options: nosniff to the SXG outer response headers.

Improve documentation

Rewrite the documentation to be action-oriented -- e.g. start with running the packager, and then move backwards up the chain to adding a FE and all that.

Improve test coverage

At the very least, go over the code, figure out what tests need adding and file bugs for them.

Support multiple certificate pairs

It may be useful for a single packager instance to sign for multiple domains that are authenticated by different certs. (This should be an uncommon case, though, as it is very simple and possibly more secure to run different instances each with access to only one certificate.)

Error out if TOML includes any unknown fields

Currently, the toml parser just silently ignores any fields that don't match the struct. This means that typos are hard to diagnose, and backwards-incompatible changes to the config will require special care to notify existing users.

rtv support

Periodically (hourly?) poll to get the latest rtv (and css url), store in memory.

Pass these values into the local transformer library for writing the correct rtv script and css.

Automatically fetch SCT

https://github.com/WICG/webpackage/pull/267/files added some instructions on submitting a cert to CT and getting an SCT in return, in cases where the CA has not already attached it. This would be nice for the packager to support automatically, though not strictly necessary. At the very least, the documentation should be updated to include a reference to this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.