Skip to content

Use a least-privilege SQL identity for the app - #73

Open
mageroni with github-agentic-autofix[bot] wants to merge 2 commits into
mainfrom
agentic-autofix/fix-code-scanning-alerts
Open

mageroni with github-agentic-autofix[bot] wants to merge 2 commits into
mainfrom
agentic-autofix/fix-code-scanning-alerts

Conversation

@github-agentic-autofix

@github-agentic-autofix github-agentic-autofix AI commented Nov 12, 2026 •

Copy link
Copy Markdown

The app’s database connection used the SQL server administrator login, giving a compromised app broader privileges than needed.

  • Deployment: Use the contained copilotSurveyApp database user and a separate secure sqlApplicationLoginPassword parameter.

  • Provisioning: Document the minimum database permissions required by the app:

    CREATE USER [copilotSurveyApp] WITH PASSWORD = '<application-password>';
    GRANT CREATE TABLE TO [copilotSurveyApp];
    GRANT ALTER ON SCHEMA::dbo TO [copilotSurveyApp];
    GRANT SELECT, INSERT, UPDATE ON SCHEMA::dbo TO [copilotSurveyApp];

Co-authored-by: mageroni <107436170+mageroni@users.noreply.github.com>
@github-agentic-autofix github-agentic-autofix AI changed the title [WIP] Fix code scanning alerts flagged in repository Use a least-privilege SQL identity for the app Nov 12, 2026
GitHub Agentic Autofix finished work on behalf of mageroni November 12, 2026 16:29
@github-agentic-autofix
github-agentic-autofix AI marked this pull request as ready for review November 12, 2026 16:29
Copilot AI dynamic review requested due to automatic review settings November 12, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The README’s SQL provisioning guidance leaves excessive permissions on the runtime identity and omits application-user setup and database-access instructions needed across both deployment paths.

2 open issues
What changed in this PR

This PR separates the Bicep-deployed app’s Azure SQL credentials from the server administrator account, reducing the app’s database privileges.

Changes:

  • Adds a secure application-password parameter and switches the connection string to copilotSurveyApp.
  • Documents manual user provisioning and permissions for table creation and survey reads/writes.
File Description
README.md Documents the contained database user and required permissions.
deployment/​template.bicep Adds separate application credentials and replaces administrator credentials in the app connection string.

Review effort: Max (auto)

Comment thread README.md

You can use this link to deploy all resources automatically in your Azure subscription [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmageroni%2Fcopilot-survey-engine%2Fmain%2Fdeployment%2Ftemplate.json)

For deployments using `deployment/template.bicep`, configure the app's SQL credentials separately from the SQL server administrator credentials. Before starting the app, create a contained database user named `copilotSurveyApp` in the `copilotUsage` database using the password supplied as `sqlApplicationLoginPassword`. Grant that user only the permissions needed by the app:
Comment thread README.md
GRANT SELECT, INSERT, UPDATE ON SCHEMA::dbo TO [copilotSurveyApp];
```

The app creates `SurveyResults` on first use and then reads and writes survey responses. Do not use the SQL server administrator credentials for the app connection.
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

Successfully merging this pull request may close these issues.

3 participants