Repository navigation
fix: empty options, GET with an empty body, and crypt on Cloudflare Pages - #40
Merged
Merged
Conversation
A proxy can copy a header that its client did not send, as an empty header. Before, rfetch took such a header as an option with the value "", and the default of the option was lost. For example, an empty RFETCH_S3_REGION gave the region "". Now a header RFETCH_* or RCLONE_* with an empty value is not an option and not a variable, in the backends (optionsOf) and in the remotes of the variables (RFETCH_CONFIG_NAME_*). The next place gives the value: a header of the other prefix, a variable of the environment, or the default. An empty RFETCH_CONFIG_NAME_TYPE gives no remote.
The Worker gives the fields of the query to the remote as the parameters of a connection string, and a parameter takes the place of a header. A proxy can copy a field that its client did not send, as an empty field: then `?remote=` gave the option remote="", and the header RFETCH_ALIAS_REMOTE of the client was lost. Now the Worker gives no parameter for a field with an empty value, as for a header with an empty value.
workerd gives a body stream to a GET with Content-Length: 0. The Worker gave that body to fetch(), and fetch() refuses a GET or a HEAD with a body, so the request failed with the error 1101. Now the Worker gives a body only to the other methods.
Each error of the keys gave "The password is not obscured", also an error of scrypt or of AES-256 in node:crypto. Now only a password or a salt that reveal cannot read gives that answer (400). A different error gives 500 with its cause, with no part of the password.
In a build of Cloudflare Pages, createCipheriv of node:crypto is a stub of unenv that throws, so crypt could not make the cipher of the names. aes256 still uses AES-256-ECB of node:crypto, and takes aes256js when createCipheriv throws: AES-256 as FIPS-197, in JavaScript, with no dependency. The tests compare it with the vector of FIPS-197, with node:crypto on random keys and blocks, and with the vectors of EME.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five fixes for rfetch as a Worker:
RFETCH_*orRCLONE_*with an empty value, and a field of the query with an empty value, are not options. Before, an empty value took the place of the default of rclone, or of a value in a different place.Content-Length: 0. The Worker gave that body tofetch(), andfetch()refuses a GET or a HEAD with a body, so the request failed with the error 1101. Now the Worker gives a body only to the other methods.revealcannot read gives that answer (400). A different error gives 500 with its cause, with no part of the password.createCipherivofnode:cryptois a stub of unenv that throws: "[unenv] crypto.createCipheriv is not implemented yet!". Thus crypt could not make the cipher of the names, and each request failed.aes256still uses AES-256-ECB ofnode:crypto. WhencreateCipherivthrows, it usesaes256js: AES-256 as FIPS-197, in JavaScript, with no dependency.scrypt,createHashandcreateHmacofnode:cryptowork in that build, so s3 worked before too.Tests
worker_test.js:backend/crypt/main_test.js:backend/crypt/aes_test.js:aes256jsgives the vector of FIPS-197, appendix C.3.node:cryptoon random keys and blocks.aes256uses it whencreateCipherivthrows.backend/crypt/eme_test.js: the vectors of EME pass with the two ciphers.npm test: 1,187 tests, 1,173 pass, 14 skip because a tool is not installed.deno fmt --checkpasses.Check on the preview of this branch
Done with an R2 bucket as the remote of crypt:
dir/a file.txtgives 201.Accept: application/json) showsa file.txt. R2 keeps only the encrypted names.