Skip to content
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

"Duplicate timestamp/nonce combination, possible replay attack. Request rejected." #79

Closed
ThatNerdyPikachu opened this issue Jan 12, 2019 · 2 comments

Comments

@ThatNerdyPikachu
Copy link

ThatNerdyPikachu commented Jan 12, 2019

Got Duplicate timestamp/nonce combination, possible replay attack. Request rejected. while trying to authorize in headers, which is the only thing that this API accepts.

function getOAuth(consumer_key, consumer_secret) {
	return OAuth({
		consumer: {
			key: consumer_key,
			secret: consumer_secret
		},
		signature_method: "HMAC-SHA1",
		hash_function: function(base_string, key) {
			return crypto.createHmac("sha1", key).update(base_string).digest("base64")
		}
	})
}

// ...

router.get("/api/me", function(req, res) {
	if (!req.query.key || !req.query.secret) {
		return res.status(400).end()
	}

	const oauth = getOAuth(req.query.key, req.query.secret)

	const request = {
		url: "<redacted>",
		method: "GET"
	}

	axios.get(request.url, {
		headers: oauth.toHeader(oauth.authorize(request))
	})
	.then(function(response) {
		res.send(response.data)
	})
	.catch(function(err) {
		res.send(err.response.data)
	})
})
@ddo
Copy link
Owner

ddo commented Jun 5, 2019

or some clouds or serverless services Math.random could return the same fyi

@ddo ddo closed this as completed Jun 5, 2019
@JonnyOThan
Copy link

For anyone coming across this issue, I was banging my head against it for a few hours until I finally used Fiddler to look at the requests and responses.

The server was responding with a 302 redirect, and my http library was helpfully following the redirect and sending the same headers - which of course included the duplicate nonce and timestamp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants