-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trust-Signal: A New HTTP Header for Verifying Server Authenticity through Cryptographic Signatures #466
Comments
Do you want to calculate the hash and signature of the response body? If the response is provided directly from the local disk, it is possible to calculate the hash and signature. However, it is obviously against the principle of performance priority to calculate the same content repeatedly. Therefore, even if it is implemented, the hash and signature values must be prepared in advance and stored together with the original file, just like the gzip_static module. The gzip_static module will distribute filename.sign to the client, and this hypothetical module should only put the value of filename.hash in the Trust-Signal header. If the response comes from upstream (using proxy_pass and other scenarios), this requires that the response body is fully buffered, that is, the response body must be completely pulled from the upstream, and the signature must be calculated before the response header and response body can be provided to the downstream. This scenario will have a very serious performance degradation for the distribution of larger files. In this case, the signature should be provided by the upstream server instead of nginx. |
Thank you for your detailed feedback and insights regarding the Trust-Signal proposal.
Additional Considerations:To ensure this feature aligns with Nginx's principles and user needs, I am happy to:
I strongly believe that the Thank you |
1. Case: Hash and Signature for Local Disk ResourcesSolution Approach
Implementation Steps(a) Precompute Hash ValuesUse a script to calculate and store hash values for static files in the directory. #!/bin/bash
STATIC_DIR="/var/www/html/static"
for file in "$STATIC_DIR"/*; do
if [[ -f "$file" ]]; then
sha256sum "$file" | awk '{print $1}' > "$file.hash"
fi
done (b) Modify NGINX ConfigurationInstruct NGINX to append the precomputed hash value to the http {
server {
listen 80;
server_name example.com;
location /static/ {
root /var/www/html;
header_filter_by_lua_block {
local filepath = ngx.var.request_filename .. ".hash"
local file = io.open(filepath, "r")
if file then
local hash = file:read("*a")
file:close()
if hash then
ngx.header["Trust-Signal"] = hash:gsub("%s+", "")
end
end
}
}
}
} (c) Reload NGINXsudo nginx -t && sudo systemctl reload nginx (d) Test the Responsecurl -I http://example.com/static/sample.txt Expected Output:
2. Case: Handling Upstream ResponsesSolution Approach
Implementation Steps(a) Upstream Server ConfigurationThe upstream server (e.g., another NGINX instance or application server) must calculate the hash of the response body and include it in the response header. Example Code (Python Flask as upstream server): from flask import Flask, request, Response
import hashlib
app = Flask(__name__)
@app.route('/api/data', methods=['GET'])
def serve_data():
data = "This is the response body."
hash_value = hashlib.sha256(data.encode()).hexdigest()
response = Response(data, status=200, mimetype='text/plain')
response.headers["X-Upstream-Hash"] = hash_value
return response
if __name__ == '__main__':
app.run(port=8081) (b) NGINX Proxy ConfigurationModify NGINX to forward requests to the upstream server and include the upstream hash as the http {
server {
listen 80;
server_name example.com;
location /proxy/ {
proxy_pass http://localhost:8081/api/data;
header_filter_by_lua_block {
local upstream_hash = ngx.header["X-Upstream-Hash"]
if upstream_hash then
ngx.header["Trust-Signal"] = upstream_hash
end
}
}
}
} (c) Test the Responsecurl -I http://example.com/proxy/ Expected Output:
Performance Considerations
Please Let me know if you have any further questions. This is a small demo of your questions with possible practical solutions Thank you |
My idea is new and I want to mainstream this. To get support of industry. That's why i put my proposal here. I think it will work with nginx. Because it will give secure way to explore internet through nginx. Trust-Signal is very much in developing stage. Looking to support for my this from open community. Thank you and God Bless You all 😊 |
Proposal for HTTP Trust-Signal Header
Title:
Trust-Signal: A New HTTP Header for Verifying Server Authenticity through Cryptographic Signatures
Abstract:
The Trust-Signal HTTP header introduces a mechanism for verifying server authenticity by allowing web servers to sign their responses with a cryptographic signature. This header is designed to provide an additional layer of security, ensuring that responses come from trusted sources, and mitigating risks of man-in-the-middle attacks, phishing, and server impersonation. It provides a verifiable way for clients to confirm the integrity and origin of the data they receive.
Problem Statement:
Web security mechanisms, such as HTTPS (TLS/SSL) and certificates, are widely deployed but do not provide fine-grained verification for every response from the server. In some scenarios, users or applications need to verify the authenticity of the data they receive on a per-response basis, beyond the generic connection encryption and server certification.
For example:
Proposed Solution:
The Trust-Signal HTTP header would provide a cryptographic signature for each HTTP response, ensuring the client can verify the server’s identity and data integrity for each transaction.
Trust-Signal Header Format:
Trust-Signal: verified; sig=<signature>
Where:
How It Works:
Server-Side:
Trust-Signal
header, appending the cryptographic signature.Client-Side:
Use Cases:
Anti-Phishing:
Clients can verify that the content they receive comes from the expected trusted source and not a fraudulent impersonator.
Man-in-the-Middle Protection:
Even if an attacker intercepts and modifies the response, the altered response will fail the cryptographic verification, protecting the integrity of the data.
Sensitive Transactions:
Applications requiring high security, such as banking or e-commerce, could use the
Trust-Signal
header to ensure that every critical action, like making payments or transferring sensitive data, is trusted and authenticated.Security Considerations:
Example Implementation:
Benefits:
Conclusion:
The Trust-Signal header offers a novel way to enhance HTTP security by providing per-response cryptographic authentication. This proposal aims to give users and applications more control over the trustworthiness of responses, addressing vulnerabilities that may not be fully covered by existing mechanisms.
Let me know if you have any questions
The text was updated successfully, but these errors were encountered: