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

Secure cookies not being sent over localhost #3457

Open
Tom-Dann opened this issue Nov 16, 2023 · 1 comment
Open

Secure cookies not being sent over localhost #3457

Tom-Dann opened this issue Nov 16, 2023 · 1 comment
Labels
enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 new-http issues that would require (or benefit from) a new HTTP API

Comments

@Tom-Dann
Copy link

Brief summary

When calling a service on localhost, if cookies are set with Secure: true they are not sent in following requests if the connection is over HTTP.

As per documentation secure cookies should only be sent over HTTPS except in the case of requests on localhost. See Set-Cookie header documentation.

k6 version

0.47.0

OS

macOS 13

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Run the following k6 script, which sets two cookies on http://localhost, one with the secure flag set to false and the other to true

import http from 'k6/http'

export default function () {
  const jar = http.cookieJar()
  const url = 'http://localhost'
  jar.set(url, 'insecure_cookie', 'val1', { secure: false })
  jar.set(url, 'secure_cookie', 'val2', { secure: true })
  console.log(jar.cookiesForURL(url))
}

Expected behaviour

As per Set-Cookie documentation k6 should output both cookies to the console

{"insecure_cookie":["val1"],"secure_cookie":["val2"]}

Actual behaviour

The actual output to console is only the cookie without the secure flag set to true

{"insecure_cookie":["val1"]}
@Tom-Dann
Copy link
Author

Looking at the k6 code this behaviour comes from the underlying net/http/cookiejar Go implementation.

Related issue: golang/go#60997

@codebien codebien added enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 new-http issues that would require (or benefit from) a new HTTP API and removed triage bug labels Nov 22, 2023
@codebien codebien removed their assignment Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 new-http issues that would require (or benefit from) a new HTTP API
Projects
None yet
Development

No branches or pull requests

2 participants