Skip to content

Commit d843d13

Browse files
committed
updated to check against 'Signature-256' request header (fixes #47)
1 parent 48dfece commit d843d13

File tree

9 files changed

+1917
-1113
lines changed

9 files changed

+1917
-1113
lines changed

.github/workflows/main.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@ jobs:
2121
# The type of runner that the job will run on
2222
runs-on: ubuntu-latest
2323

24+
# Specify which node versions should this module be tested against
25+
strategy:
26+
matrix:
27+
node-version: [ 12, 14, 16, 18, 20 ]
28+
2429
# Steps represent a sequence of tasks that will be executed as part of the job
2530
steps:
2631
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2732
- uses: actions/checkout@v4
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: ${{ matrix.node-version }}
2836

2937
# Runs a single command using the runners shell
3038
- name: setup
31-
run: npm install
39+
run: npm ci
3240

3341
# Runs a single command using the runners shell
3442
- name: tests

.gitignore

+89-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
logs
33
*.log
44
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
512

613
# Runtime data
714
pids
@@ -14,29 +21,48 @@ lib-cov
1421

1522
# Coverage directory used by tools like istanbul
1623
coverage
24+
*.lcov
1725

1826
# nyc test coverage
1927
.nyc_output
2028

21-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
2230
.grunt
2331

32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
2435
# node-waf configuration
2536
.lock-wscript
2637

27-
# Compiled binary addons (http://nodejs.org/api/addons.html)
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
2839
build/Release
2940

3041
# Dependency directories
31-
node_modules
32-
jspm_packages
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
3350

3451
# Optional npm cache directory
3552
.npm
3653

3754
# Optional eslint cache
3855
.eslintcache
3956

57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
4066
# Optional REPL history
4167
.node_repl_history
4268

@@ -46,3 +72,62 @@ jspm_packages
4672
# Yarn Integrity file
4773
.yarn-integrity
4874

75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
132+
# node-TAP generated files
133+
.tap

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.0.0
2+
* BREAKING: Updated to check against SHA-256 signature of request body (#47)
3+
4+
15
## 2.0.3
26
* Remediates CVE-2021-3765
37

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# alexa-verifier-middleware
22

3-
[![NPM](https://nodei.co/npm/alexa-verifier-middleware.png)](https://www.npmjs.com/package/alexa-verifier-middleware/)
4-
53
![NPM Version](https://img.shields.io/npm/v/alexa-verifier-middleware.svg)
64

7-
![example workflow](https://github.com/alexa-js/alexa-verifier-middleware/actions/workflows/main.yml/badge.svg)
5+
![Github CI status](https://github.com/alexa-js/alexa-verifier-middleware/actions/workflows/main.yml/badge.svg)
86

97
An [express](https://www.npmjs.com/package/express) middleware that verifies HTTP requests sent to an Alexa skill are sent from Amazon.
108

119

12-
Version 2.x is now a pure es module, and requires node 12.17 or higher. If you want to run this via an older version of node, use
10+
Version 3.x is now a pure ES module, and requires node 12.17 or higher. If you want to run this via an older version of node, use
1311
[[email protected]](https://www.npmjs.com/package/alexa-verifier-middleware/v/1.0.3)
1412

1513

index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default function alexaVerifierMiddleware (req, res, next) {
1919
// other body parser middlewares
2020
req._body = true
2121
req.rawBody = ''
22+
2223
req.on('data', function (data) {
2324
return req.rawBody += data
2425
})
@@ -33,8 +34,8 @@ export default function alexaVerifierMiddleware (req, res, next) {
3334
req.body = { }
3435
}
3536

36-
certUrl = req.headers.signaturecertchainurl
37-
signature = req.headers.signature
37+
certUrl = req.headers['signaturecertchainurl']
38+
signature = req.headers['signature-256']
3839

3940
verifier(certUrl, signature, req.rawBody, function (er) {
4041
if (er)

0 commit comments

Comments
 (0)