# Windows Security Questions stored in the LSA

Podalirius · 2021-10-04

<https://podalirius.net/en/windows/windows-account-security-questions-stored-in-the-lsa/>

Windows account security questions are a good way to recover your password. Where and how are they stored? How to extract them?

## Introduction

Windows account security questions were introduced in Windows 10 1803 (in April 2018) to provide users with a means of password recovery.

## Storage and format

This secret is stored in the Local Security Authority (LSA) and is named in the format `L$_SQSA_<SID>`, with:
 - `L$` - Local Secret
 - `SQSA` - Security Questions Security Answers
 - `SID` - Security identifier

The format of this secret is a character string encoded in UTF-16-LE containing a JSON dictionary:

```json
{
  "version":1,
  "questions": [
    {
      "question":"What was your childhood nickname",
      "answer":"John"
    },
    {
      "question":"What is the first name of your oldest cousin?",
      "answer":"Jack"
    },
    {
      "question":"What was your first pet’s name?",
      "answer":"Fluffy"
    }
  ]
}
```

## Implementation in the tools

### Secretsdump of the Impacket suite

In the file [impacket/examples/secretsdump.py](https://github.com/fortra/impacket/blob/master/impacket/examples/secretsdump.py) I added these few lines of python to automatically parse and format the security questions in the output of the [secretsdump](https://github.com/fortra/impacket/blob/master/examples/secretsdump.py) tool:

```python
elif re.match('^L\$_SQSA_(S-[0-9]-[0-9]-([0-9])+-([0-9])+-([0-9])+-([0-9])+-([0-9])+)$', upperName) is not None:
    # Decode stored security questions
    sid = re.search('^L\$_SQSA_(S-[0-9]-[0-9]-([0-9])+-([0-9])+-([0-9])+-([0-9])+-([0-9])+)$', upperName).group(1)
    try:
        strDecoded = secretItem.decode('utf-16le').replace('\xa0',' ')
        strDecoded = json.loads(strDecoded)
    except:
        pass
    else:
        output = []
        if strDecoded['version'] == 2:
            output.append(" - Version : %d" % strDecoded['version'])
            for qk in strDecoded['questions']:
                output.append(" | Question: %s" % qk['question'])
                output.append(" | └──> Answer: %s" % qk['answer'])
            output = '\n'.join(output)
            secret = 'Security Questions for user %s: \n%s' % (sid, output)
        else:
            LOG.warning("Unknown SQSA version (%s), please open an issue with the following data so we can add a parser for it." % str(strDecoded['version']))
            LOG.warning("Don't forget to remove sensitive content before sending the data in a Github issue.")
            secret = json.dumps(strDecoded, indent=4)
```

The output of the [secretsdump](https://github.com/fortra/impacket/blob/master/examples/secretsdump.py) tool now becomes:

![](<https://podalirius.net/en/windows/windows-account-security-questions-stored-in-the-lsa/secretsdump_output.png>)

I created a [pull request](https://github.com/fortra/impacket/pull/1174) to add this feature directly in [impacket](https://github.com/fortra/impacket/).

[fortra/impacket](<https://github.com/fortra/impacket>)





## References
 - [https://i.blackhat.com/eu-18/Wed-Dec-5/eu-18-Baz-When-Everyones-Dog-Is-Named-Fluffy.pdf](https://i.blackhat.com/eu-18/Wed-Dec-5/eu-18-Baz-When-Everyones-Dog-Is-Named-Fluffy.pdf)
 - [https://illusive.com/blog/threat-research-blog/when-everyones-dog-is-named-fluffy/](https://illusive.com/blog/threat-research-blog/when-everyones-dog-is-named-fluffy/)
 - [https://www.nirsoft.net/utils/security_questions_view.html](https://www.nirsoft.net/utils/security_questions_view.html)
