Nobody has started this yet — be first.
Business impact
Every password-reset token and email-verification token this service issues is single-use but still a live credential for up to 24 hours or 30 minutes. Sending them over an unencrypted SMTP connection means anyone positioned on the network path between this app and the mail server can read them in plaintext and take over the account before the legitimate user even opens their inbox. This is also the kind of finding that fails a SOC 2 / PCI audit outright and can block enterprise deals.
Problem
SMTPEmailSender.send() has an inverted TLS condition: if not self.use_tls: smtp.starttls() attempts STARTTLS only when TLS was explicitly turned off, and skips it whenever TLS is on -- the exact opposite of every deployment's intent, including the documented default of SMTP_USE_TLS=true.
Current behavior
Constructing SMTPEmailSender(..., use_tls=True) and calling .send() never calls smtp.starttls(), so the email goes out over an unencrypted connection.
Expected behavior
SMTPEmailSender.send() calls smtp.starttls() when use_tls=True, and does not call it when use_tls=False.
Steps to reproduce
Why this matters
An inverted boolean condition is one of the easiest single-token mistakes to introduce and one of the easiest to miss in review, because both branches of the if are individually reasonable-looking code -- the bug is only visible when you check the condition against the variable's name and documented meaning, not just its syntax.
Suggested approach
Read the condition against what use_tls is supposed to mean (its name is not "skip_tls"), and check it against MailerExtension.init_app()'s comment about the documented SMTP_USE_TLS default.
Acceptance criteria
Verification
pytest practice_tickets/tests/test_ticket_06.py -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
Sign in to create it automatically, or do it yourself:
$git checkout -b fix/smtp-tls-invertedFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/smtp-tls-invertedSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign inhttp://localhost:5000make seedpyotpmake docker-prod-upYou do not need Docker running at all to work the tickets -- the test suite uses an in-memory SQLite database (via StaticPool, an isolated DB per test function) and fakeredis (TestingConfig.USE_FAKE_REDIS), so everything runs against a plain virtualenv:
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pytest practice_tickets/tests/test_ticket_01.py -v # a single ticket
./practice_tickets/run_tickets.sh # all 15, clean pass/fail summary
All 15 tests fail at the start; as you fix each ticket in app/, its test (and only its test) should flip to passing. make test (pytest -q) runs the project's own main suite -- as of writing it shows 9 pre-existing failures caused by ticket bugs 02, 03, 07, 11, and 15; fixing those tickets fixes those failures too, not a separate task. Do not look at git diff / version control history to find the bugs if this repo is ever put under source control -- the point is to find them the way you would find a real bug: from a failing test and a description of broken behavior, not a diff.
Level 1
Fix a bug
Read existing behaviour, correct it.